Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new #173

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

new #173

2 changes: 1 addition & 1 deletion .env.example → .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Your API Key for GEMINI_API
GEMINI_API_KEY=
GEMINI_API_KEY=AIzaSyCtrmT3JUvtG6SkYSPSa8w67Fta6yXf1U0
# Custom base url for OpenAI API. default: https://generativelanguage.googleapis.com
API_BASE_URL=
# Inject analytics or other scripts before </head> of the page
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>

<p class="flex flex-wrap justify-center items-center text-xs op-30 my-2">
© 2023&nbsp;<a href="https://geminiprochat.com" target="_blank" class="font-bold">Gemini Pro Chat</a>. All rights reserved.
© 2023&nbsp;<a href="https://chat.isoy.cloud/" target="_blank" class="font-bold">Gemini Pro Chat</a>. All rights reserved.
</p>

<div class="flex flex-wrap justify-center items-center text-xs op-30 my-2">
Expand Down
8 changes: 4 additions & 4 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import Themetoggle from './Themetoggle.astro'
<Themetoggle />
</div>
<div class="fi mt-2">
<a href="https://geminiprochat.com" class="gpt-title">Gemini Pro</a>
<a href="https://geminiprochat.com" class="gpt-subtitle">Chat</a>
<a href="https://chat.isoy.cloud/" class="gpt-title">EASY AI</a>
<a href="https://chat.isoy.cloud/" class="gpt-subtitle">Chat</a>
</div>
<p mt-1 op-60>
Based on
<a href="https://blog.geminiprochat.com/posts/what-is-gemini"> Gemini Pro API.</a>
<a href="https://github.com/babaohuang/GeminiProChat" class="font-bold">Source code</a>
<a href="https://chat.isoy.cloud/">EASY AI.</a>
<a href="https://chat.isoy.cloud/" class="font-bold">Developer Adonis</a>
</p>
</header>
2 changes: 1 addition & 1 deletion src/components/SystemRoleSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default (props: Props) => {
<div>
<textarea
ref={systemInputRef!}
placeholder="You are a helpful assistant, answer as concisely as possible...."
placeholder="You are EASY AI developed by ADONIS JR S under EASY API headed by Adonis himself."
autocomplete="off"
autofocus
rows="3"
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

export interface ChatPart {
text: string
}
Expand All @@ -11,3 +12,4 @@ export interface ErrorMessage {
code: string
message: string
}
export const defaultChatMessage = "I'm EASY AI developed by ADONIS JR S under EASY API headed by Adonis himself.";
9 changes: 8 additions & 1 deletion src/utils/openAI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GoogleGenerativeAI } from '@fuyun/generative-ai'
import { ChatMessage } from '../types' // Import ChatMessage only

const apiKey = (import.meta.env.GEMINI_API_KEY)
const apiBaseUrl = (import.meta.env.API_BASE_URL)?.trim().replace(/\/$/, '')
Expand All @@ -7,9 +8,15 @@ const genAI = apiBaseUrl
? new GoogleGenerativeAI(apiKey, apiBaseUrl)
: new GoogleGenerativeAI(apiKey)

export const startChatAndSendMessageStream = async(history: ChatMessage[], newMessage: string) => {
export const startChatAndSendMessageStream = async (history: ChatMessage[], newMessage: string) => {
const model = genAI.getGenerativeModel({ model: 'gemini-pro' })

// Always insert the default message into the history
history.push({
role: 'model',
parts: [{ text: "I'm EASY AI developed by ADONIS Jr. S under EASY API headed by Adonis himself." }] // Default message
});

const chat = model.startChat({
history: history.map(msg => ({
role: msg.role,
Expand Down