Pulkit-exe commited on
Commit
5a2c7b1
·
verified ·
1 Parent(s): dcf49e5

Used New Serverless Inference Calls

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -9,7 +9,7 @@ import gradio as gr
9
  CHROMA_PATH = "chroma"
10
 
11
  # Hugging Face API setup
12
- repo_id = "Qwen/Qwen2.5-Coder-32B-Instruct"
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
- llm = HuggingFaceEndpoint(
44
- repo_id=repo_id,
45
- temperature=0.2,
46
  )
47
 
48
  def generate_response(self, prompt):
49
- return self.llm.invoke(prompt)
 
 
 
 
 
 
 
 
 
 
 
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():