-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Guess next digest name * Fix storage * Fix env var * Fix for key * Save digest predicted title on digest publication * Remove DigestGuessTitle Component * Add conditions to open ai search
- Loading branch information
Showing
11 changed files
with
293 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ NEXT_PUBLIC_SLACK_CLIENT_ID= | |
SLACK_CLIENT_SECRET= | ||
NEXT_PUBLIC_SENTRY_DSN=https://[email protected]/xxx | ||
TYPEFULLY_API_URL="https://api.typefully.com/v1" | ||
JWT_SECRET="secret" | ||
JWT_SECRET="secret" | ||
OPENAI_API_KEY='my apiKey' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,6 +266,12 @@ | |
"string", | ||
"null" | ||
] | ||
}, | ||
"nextSuggestedDigestTitle": { | ||
"type": [ | ||
"string", | ||
"null" | ||
] | ||
} | ||
} | ||
}, | ||
|
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20231003081810_predict_digest_name/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "teams" ADD COLUMN "nextSuggestedDigestTitle" TEXT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import OpenAI from 'openai'; | ||
import { OpenAIStream, StreamingTextResponse } from 'ai'; | ||
|
||
// Create an OpenAI API client (that's edge friendly!) | ||
const openai = new OpenAI({ | ||
apiKey: process.env.OPENAI_API_KEY!, | ||
}); | ||
|
||
// IMPORTANT! Set the runtime to edge | ||
export const runtime = 'edge'; | ||
|
||
export async function POST(req: Request) { | ||
// Extract the `messages` from the body of the request | ||
const { messages } = await req.json(); | ||
|
||
// Ask OpenAI for a streaming chat completion given the prompt | ||
const response = await openai.chat.completions.create({ | ||
model: 'gpt-3.5-turbo', | ||
stream: true, | ||
messages, | ||
}); | ||
// Convert the response into a friendly text-stream | ||
const stream = OpenAIStream(response); | ||
// Respond with the stream | ||
return new StreamingTextResponse(stream); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import OpenAI from 'openai'; | ||
|
||
const openai = new OpenAI({ | ||
apiKey: process.env.OPENAI_API_KEY!, | ||
}); | ||
|
||
export const openAiCompletion = async (prompt: string) => { | ||
const chatCompletion = await openai.chat.completions.create({ | ||
messages: [{ role: 'user', content: prompt }], | ||
model: 'gpt-3.5-turbo', | ||
}); | ||
|
||
return chatCompletion.choices; | ||
}; |
Oops, something went wrong.
0f304fd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
digestclub – ./
digestclub-git-main-premieroctet.vercel.app
digestclub-premieroctet.vercel.app
digestclub.vercel.app