Skip to content

Commit

Permalink
reuse same assistant id for chat assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
lluisd committed Nov 9, 2024
1 parent f8d3169 commit 8312767
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main_twitch-mz-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
envkey_TWITCH_EVENTSUB_SECRET: ${{ secrets.TWITCH_EVENTSUB_SECRET }}
envkey_TWITCH_HOSTNAME: ${{ secrets.TWITCH_HOSTNAME }}
envkey_WHISPER_ENDPOINT: ${{ secrets.WHISPER_ENDPOINT }}
envkey_AZURE_OPENAI_ASSISTANT_ID: ${{ secrets.AZURE_OPENAI_ASSISTANT_ID }}
- name: Set up Node.js version
uses: actions/setup-node@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ module.exports = {
key: process.env.AZURE_OPENAI_KEY,
apiVersion: process.env.AZURE_OPENAI_API_VERSION,
database: process.env.OPENAI_MONGODB_URI,
vectorStoreId: process.env.AZURE_OPENAI_VECTOR_STORE_ID
vectorStoreId: process.env.AZURE_OPENAI_VECTOR_STORE_ID,
assistantId: process.env.AZURE_OPENAI_ASSISTANT_ID
},
whisper: {
endpoint: process.env.WHISPER_ENDPOINT,
Expand Down
5 changes: 3 additions & 2 deletions services/openAI.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const assistantsClient = getClient();
const options = {
model: "gpt-4o-mini", // replace with model deployment name
name: config.twitch.username,
instructions: "Eres un bot del canal de twitch de " + config.twitch.username + " que conoce todas las interacciones de los usuarios de su chat",
instructions: "Eres un bot del canal de twitch del streamer llamado " + config.twitch.username + " que conoce todas las interacciones de los usuarios de su chat",
tools: [{"type":"file_search"}],
tool_resources: {"file_search":{"vector_store_ids":[config.openAI.vectorStoreId]}},
temperature: 1,
Expand Down Expand Up @@ -68,7 +68,8 @@ async function askAssistant(message) {
}
);

const assistantResponse = await assistantsClient.beta.assistants.create(options);
//const assistantResponse = await assistantsClient.beta.assistants.create(options);
const assistantResponse = await assistantsClient.beta.assistants.retrieve(config.openAI.assistantId)
// Run the thread and poll it until it is in a terminal state
const runResponse = await assistantsClient.beta.threads.runs.create(
assistantThread.id,
Expand Down

0 comments on commit 8312767

Please sign in to comment.