Skip to content

Commit

Permalink
fix: TOGETHER_API_KEY
Browse files Browse the repository at this point in the history
  • Loading branch information
shoushou1106 committed Dec 20, 2024
1 parent 44b11e8 commit 52f06af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class JsonResponse extends Response {
}

const router = AutoRouter();
const together = new Together({ apiKey: process.env.TOGETHER_API_KEY });

/**
* A simple hello page to verify the worker is working.
Expand Down Expand Up @@ -75,7 +74,7 @@ router.post('/', async (request, env) => {
);
const userPrompt = promptOption?.value;

const aiResponse = await sendToAIProvider(userPrompt || "No input");
const aiResponse = await sendToAIProvider(env.TOGETHER_API_KEY, userPrompt || "No input");
return new JsonResponse({
type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
data: {
Expand Down Expand Up @@ -113,7 +112,8 @@ const server = {
fetch: router.fetch
};

async function sendToAIProvider(prompt: string): Promise<string> {
async function sendToAIProvider(api_key: string, prompt: string): Promise<string> {
const together = new Together({ apiKey: api_key });
const response = await together.chat.completions.create({
model: "meta-llama/Llama-Vision-Free",
messages: [{ role: "user", content: prompt }],
Expand Down

0 comments on commit 52f06af

Please sign in to comment.