Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from sentence_transformers import SentenceTransformer, util
|
| 3 |
import openai
|
|
|
|
| 4 |
import os
|
| 5 |
|
| 6 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
@@ -9,7 +10,7 @@ os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
| 9 |
filename = "output_topic_details.txt" # Path to the file storing chess-specific details
|
| 10 |
retrieval_model_name = 'output/sentence-transformer-finetuned/'
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
system_message = "You are a chatbot specialized in providing information the Young Yale Global Scholars program. You will be giving information to be applicants and scholars."
|
| 15 |
# Initial system message to set the behavior of the assistant
|
|
@@ -72,15 +73,17 @@ def generate_response(user_query, relevant_segment):
|
|
| 72 |
# Append user's message to messages list
|
| 73 |
messages.append({"role": "user", "content": user_message})
|
| 74 |
|
| 75 |
-
response =
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
| 84 |
|
| 85 |
# Extract the response text
|
| 86 |
output_text = response['choices'][0]['message']['content'].strip()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from sentence_transformers import SentenceTransformer, util
|
| 3 |
import openai
|
| 4 |
+
from openai import OpenAI
|
| 5 |
import os
|
| 6 |
|
| 7 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
|
|
| 10 |
filename = "output_topic_details.txt" # Path to the file storing chess-specific details
|
| 11 |
retrieval_model_name = 'output/sentence-transformer-finetuned/'
|
| 12 |
|
| 13 |
+
client = OpenAI(api_key="DEEPSEEK_API", base_url="https://api.deepseek.com")
|
| 14 |
|
| 15 |
system_message = "You are a chatbot specialized in providing information the Young Yale Global Scholars program. You will be giving information to be applicants and scholars."
|
| 16 |
# Initial system message to set the behavior of the assistant
|
|
|
|
| 73 |
# Append user's message to messages list
|
| 74 |
messages.append({"role": "user", "content": user_message})
|
| 75 |
|
| 76 |
+
response = client.chat.completions.create(
|
| 77 |
+
model="deepseek-chat",
|
| 78 |
+
messages=[
|
| 79 |
+
{"role": "system", "content": "You are a helpful assistant"},
|
| 80 |
+
{"role": "user", "content": "Hello"},
|
| 81 |
+
],
|
| 82 |
+
max_tokens=1024,
|
| 83 |
+
temperature=0.7,
|
| 84 |
+
stream=False
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
|
| 88 |
# Extract the response text
|
| 89 |
output_text = response['choices'][0]['message']['content'].strip()
|