Spaces:
Sleeping
Sleeping
model is now enviromental variable LLM_MODEL
Browse files
app.py
CHANGED
|
@@ -6,6 +6,14 @@ import gradio as gr
|
|
| 6 |
import time
|
| 7 |
import re
|
| 8 |
#export GRADIO_DEBUG=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def search_inspire(query, size=10):
|
| 11 |
"""
|
|
@@ -71,7 +79,7 @@ def llm_expand_query(query):
|
|
| 71 |
""" Expands a query to variations of fulltext searches """
|
| 72 |
|
| 73 |
response = client.chat.completions.create(
|
| 74 |
-
model=
|
| 75 |
messages=[
|
| 76 |
{
|
| 77 |
"role": "user",
|
|
@@ -120,7 +128,7 @@ def llm_generate_answer(prompt):
|
|
| 120 |
""" Generate a response from the LLM """
|
| 121 |
|
| 122 |
response = client.chat.completions.create(
|
| 123 |
-
model=
|
| 124 |
messages=[
|
| 125 |
{
|
| 126 |
"role": "system",
|
|
|
|
| 6 |
import time
|
| 7 |
import re
|
| 8 |
#export GRADIO_DEBUG=1
|
| 9 |
+
# ----------- CONFIGURATION ----------------------------------------------------
|
| 10 |
+
# OPENAI_API_KEY must be set in the environment
|
| 11 |
+
|
| 12 |
+
# Model name for LLM calls. Can be overridden by setting the LLM_MODEL
|
| 13 |
+
# environment variable. Falls back to a sensible default if unset.
|
| 14 |
+
MODEL_NAME = os.getenv("LLM_MODEL", "models/gemini-flash-latest")
|
| 15 |
+
|
| 16 |
+
# LLM_MODEL_NAME must be set in the environment
|
| 17 |
|
| 18 |
def search_inspire(query, size=10):
|
| 19 |
"""
|
|
|
|
| 79 |
""" Expands a query to variations of fulltext searches """
|
| 80 |
|
| 81 |
response = client.chat.completions.create(
|
| 82 |
+
model=MODEL_NAME,
|
| 83 |
messages=[
|
| 84 |
{
|
| 85 |
"role": "user",
|
|
|
|
| 128 |
""" Generate a response from the LLM """
|
| 129 |
|
| 130 |
response = client.chat.completions.create(
|
| 131 |
+
model=MODEL_NAME,
|
| 132 |
messages=[
|
| 133 |
{
|
| 134 |
"role": "system",
|