Used New Serverless Inference Calls
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ import gradio as gr
|
|
| 9 |
CHROMA_PATH = "chroma"
|
| 10 |
|
| 11 |
# Hugging Face API setup
|
| 12 |
-
repo_id = "
|
| 13 |
|
| 14 |
PROMPT_TEMPLATE = """
|
| 15 |
Answer the question based on the context provided. If no relevant information is found, state so.
|
|
@@ -40,13 +40,23 @@ class LocalEmbeddingFunction:
|
|
| 40 |
|
| 41 |
|
| 42 |
class LLM:
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
temperature=0.2,
|
| 46 |
)
|
| 47 |
|
| 48 |
def generate_response(self, prompt):
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
def get_embedding_function():
|
|
|
|
| 9 |
CHROMA_PATH = "chroma"
|
| 10 |
|
| 11 |
# Hugging Face API setup
|
| 12 |
+
repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 13 |
|
| 14 |
PROMPT_TEMPLATE = """
|
| 15 |
Answer the question based on the context provided. If no relevant information is found, state so.
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
class LLM:
|
| 43 |
+
client = InferenceClient(
|
| 44 |
+
provider="hyperbolic",
|
|
|
|
| 45 |
)
|
| 46 |
|
| 47 |
def generate_response(self, prompt):
|
| 48 |
+
completion = client.chat.completions.create(
|
| 49 |
+
model=repo_id,
|
| 50 |
+
messages=[
|
| 51 |
+
{
|
| 52 |
+
"role": "user",
|
| 53 |
+
"content": prompt
|
| 54 |
+
}
|
| 55 |
+
],
|
| 56 |
+
max_tokens=250,
|
| 57 |
+
temperature=0.2
|
| 58 |
+
)
|
| 59 |
+
return str(completion.choices[0].message.content)
|
| 60 |
|
| 61 |
|
| 62 |
def get_embedding_function():
|