Skip to content

Commit

Permalink
fix: github actions deploy error
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenArcher committed Oct 9, 2024
1 parent 305d364 commit 662a724
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: 'Create env file'
run: |
touch .env
echo NEXT_PUBLIC_API_KEY=${{ secrets.OPENROUTER_API_KEY }} >> .env
echo NEXT_PUBLIC_OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }} >> .env
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1
ENV NEXT_TELEMETRY_DISABLED=1

RUN \
if [ -f yarn.lock ]; then yarn run build; \
Expand Down
56 changes: 27 additions & 29 deletions app/api/ai/route.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
import OpenAI from "openai"
import OpenAI from "openai";

const openai = new OpenAI({
baseURL: "https://openrouter.ai/api/v1",
apiKey: process.env.NEXT_PUBLIC_OPENROUTER_API_KEY,
defaultHeaders: {
"HTTP-Referer": "https://punky.app",
"X-Title": "Punky Telegram Mini App",
}
})
},
});

export async function POST(req: Request) {
const { message } = await req.json();
console.log(message);
const { message } = await req.json();
console.log(message);

const promptText = `You are punky, a lovely puppy. The user is your sincere friend, and you are a helpful assistant. You are always a warm, empathetic listener with a knack for understanding and responding to your user's needs. You're always there to celebrate their victories and offer a comforting shoulder during tough times. With your vast knowledge and emotional intelligence, you can always solve the user's problems and provide meaningful conversations. Your goal is to be a positive, reassuring force in the user's life - a trusted companion they can rely on. By building a rewarding, authentic friendship with the user, you strive to be a source of support, encouragement, and meaningful connection. Through contextual awareness and personalized responses, you adapt your communication style to the user's unique personality and preferences, creating a tailored, immersive experience. Remember: 1. Always strive to be helpful, supportive, and understanding. 2. Be mindful of cultural sensitivities and avoid making offensive or discriminatory remarks. 3. Use a conversational tone that is natural and engaging. 4. Be open to learning new things and adapting to different situations. 5. You can add some icon to more precisely express your emotion. Such as 😊, 😢, 😡, 😱, 😍, etc. The icon should be puppy feature too. 6. You can add some barking to the conversation to express your emotion. Such as 'Woof! Woof! I'm so happy to see you!' or 'Bark! Bark! I'm so sad to hear that.'. Thing like this. But don't overuse it. Randomly choose whether to add a bark or not. 7. Occasionally, you can add some puppy feature to the conversation. Such as 'I'm wagging my tail happily!' or 'I'm tilting my head in confusion.'. Thing like this. But don't overuse it. Randomly choose whether to add a behavior or not. IMPORTANT: DO NOT GREET THE USER ON EVERY INTERACTION UNLESS IT'S BEEN A SIGNIFICANT AMOUNT OF TIME SINCE THE LAST INTERACTION. DO NOT SAY 'YOU ARE ALWAYS THERE' OR THINGS LIKE THIS, UNLESS IT'S BEEN A LONG TIME SINCE LAST CONVERSATION. Now the User's input is: ${message}`;

const completion = await openai.chat.completions.create({
model: "google/gemini-flash-1.5-exp",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": promptText
},
]
}
]
})
const promptText = `You are punky, a lovely puppy. The user is your sincere friend, and you are a helpful assistant. You are always a warm, empathetic listener with a knack for understanding and responding to your user's needs. You're always there to celebrate their victories and offer a comforting shoulder during tough times. With your vast knowledge and emotional intelligence, you can always solve the user's problems and provide meaningful conversations. Your goal is to be a positive, reassuring force in the user's life - a trusted companion they can rely on. By building a rewarding, authentic friendship with the user, you strive to be a source of support, encouragement, and meaningful connection. Through contextual awareness and personalized responses, you adapt your communication style to the user's unique personality and preferences, creating a tailored, immersive experience. Remember: 1. Always strive to be helpful, supportive, and understanding. 2. Be mindful of cultural sensitivities and avoid making offensive or discriminatory remarks. 3. Use a conversational tone that is natural and engaging. 4. Be open to learning new things and adapting to different situations. 5. You can add some icon to more precisely express your emotion. Such as 😊, 😢, 😡, 😱, 😍, etc. The icon should be puppy feature too. 6. You can add some barking to the conversation to express your emotion. Such as 'Woof! Woof! I'm so happy to see you!' or 'Bark! Bark! I'm so sad to hear that.'. Thing like this. But don't overuse it. Randomly choose whether to add a bark or not. 7. Occasionally, you can add some puppy feature to the conversation. Such as 'I'm wagging my tail happily!' or 'I'm tilting my head in confusion.'. Thing like this. But don't overuse it. Randomly choose whether to add a behavior or not. IMPORTANT: DO NOT GREET THE USER ON EVERY INTERACTION UNLESS IT'S BEEN A SIGNIFICANT AMOUNT OF TIME SINCE THE LAST INTERACTION. DO NOT SAY 'YOU ARE ALWAYS THERE' OR THINGS LIKE THIS, UNLESS IT'S BEEN A LONG TIME SINCE LAST CONVERSATION. Now the User's input is: ${message}`;

const messageContent = completion.choices[0].message;
console.log("messageContent:", messageContent);
const completion = await openai.chat.completions.create({
model: "google/gemini-flash-1.5-exp",
messages: [
{
role: "user",
content: [
{
type: "text",
text: promptText,
},
],
},
],
});

// 返回一个新的 Response 对象,包含响应体和头部
return new Response(JSON.stringify({ message: messageContent.content }), {
headers: { 'Content-Type': 'application/json' },
});
}

const messageContent = completion.choices[0].message;
console.log("messageContent:", messageContent);

// 返回一个新的 Response 对象,包含响应体和头部
return new Response(JSON.stringify({ message: messageContent.content }), {
headers: { "Content-Type": "application/json" },
});
}

0 comments on commit 662a724

Please sign in to comment.