Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,6 @@ import os
|
|
| 4 |
import requests
|
| 5 |
from PyPDF2 import PdfReader
|
| 6 |
import gradio as gr
|
| 7 |
-
from pydantic import BaseModel
|
| 8 |
-
|
| 9 |
|
| 10 |
|
| 11 |
def push(text):
|
|
@@ -76,6 +74,7 @@ class Me:
|
|
| 76 |
|
| 77 |
def __init__(self):
|
| 78 |
# when saving secret in HF space, don't use "" :-)
|
|
|
|
| 79 |
# Initialize Open Router client using OpenAI format
|
| 80 |
# open_router_api_key = os.getenv('OPEN_ROUTER_API_KEY')
|
| 81 |
# if open_router_api_key:
|
|
@@ -156,12 +155,13 @@ If the user is engaging in discussion, try to steer them towards getting in touc
|
|
| 156 |
done = True
|
| 157 |
return response.choices[0].message.content
|
| 158 |
|
|
|
|
|
|
|
| 159 |
# response = self.gemini.chat.completions.create(
|
| 160 |
# model="gemini-2.5-flash-preview-05-20",
|
| 161 |
# messages=messages,
|
| 162 |
# tools=tools
|
| 163 |
-
# )
|
| 164 |
-
|
| 165 |
# if response.choices[0].finish_reason=="tool_calls":
|
| 166 |
# message = response.choices[0].message
|
| 167 |
# tool_calls = message.tool_calls
|
|
@@ -171,7 +171,9 @@ If the user is engaging in discussion, try to steer them towards getting in touc
|
|
| 171 |
# else:
|
| 172 |
# done = True
|
| 173 |
# return response.choices[0].message.content
|
| 174 |
-
|
|
|
|
|
|
|
| 175 |
# try:
|
| 176 |
# response = self.client.chat.completions.create(
|
| 177 |
# model="meta-llama/llama-3.3-8b-instruct:free",
|
|
@@ -191,9 +193,6 @@ If the user is engaging in discussion, try to steer them towards getting in touc
|
|
| 191 |
# return "Sorry, there was an error processing your request. Please check your API key and try again."
|
| 192 |
# return response.choices[0].message.content
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
|
| 198 |
if __name__ == "__main__":
|
| 199 |
me = Me()
|
|
|
|
| 4 |
import requests
|
| 5 |
from PyPDF2 import PdfReader
|
| 6 |
import gradio as gr
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def push(text):
|
|
|
|
| 74 |
|
| 75 |
def __init__(self):
|
| 76 |
# when saving secret in HF space, don't use "" :-)
|
| 77 |
+
|
| 78 |
# Initialize Open Router client using OpenAI format
|
| 79 |
# open_router_api_key = os.getenv('OPEN_ROUTER_API_KEY')
|
| 80 |
# if open_router_api_key:
|
|
|
|
| 155 |
done = True
|
| 156 |
return response.choices[0].message.content
|
| 157 |
|
| 158 |
+
# canonical version
|
| 159 |
+
|
| 160 |
# response = self.gemini.chat.completions.create(
|
| 161 |
# model="gemini-2.5-flash-preview-05-20",
|
| 162 |
# messages=messages,
|
| 163 |
# tools=tools
|
| 164 |
+
# )
|
|
|
|
| 165 |
# if response.choices[0].finish_reason=="tool_calls":
|
| 166 |
# message = response.choices[0].message
|
| 167 |
# tool_calls = message.tool_calls
|
|
|
|
| 171 |
# else:
|
| 172 |
# done = True
|
| 173 |
# return response.choices[0].message.content
|
| 174 |
+
|
| 175 |
+
# try n catch version
|
| 176 |
+
|
| 177 |
# try:
|
| 178 |
# response = self.client.chat.completions.create(
|
| 179 |
# model="meta-llama/llama-3.3-8b-instruct:free",
|
|
|
|
| 193 |
# return "Sorry, there was an error processing your request. Please check your API key and try again."
|
| 194 |
# return response.choices[0].message.content
|
| 195 |
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
if __name__ == "__main__":
|
| 198 |
me = Me()
|