gyulukeyi commited on
Commit
57e1e4b
1 Parent(s): 98fa539
Files changed (2) hide show
  1. app.py +12 -8
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,10 +1,11 @@
1
  import os
2
  import gradio as gr
3
- from huggingface_hub import InferenceClient
4
 
5
- client = InferenceClient(
6
- "gyulukeyi/llama3-nallm-qa-8b-240708-zve",
7
- token=os.environ.get("hf_token"),
 
8
  )
9
 
10
 
@@ -21,13 +22,16 @@ def respond(
21
  messages.append({"role": "question", "content": 질문})
22
  response = ""
23
 
24
- for message in client.chat_completion(
25
- messages,
26
- max_tokens=max_tokens,
27
  stream=True,
 
28
  temperature=temperature,
29
  top_p=top_p,
30
- ):
 
 
31
  token = message.choices[0].delta.content
32
 
33
  response += token
 
1
  import os
2
  import gradio as gr
3
+ from openai import OpenAI
4
 
5
+
6
+ client = OpenAI(
7
+ base_url="https://ueecxhqta9umllae.us-east-1.aws.endpoints.huggingface.cloud/v1/",
8
+ api_key=os.environ.get("hf_token"),
9
  )
10
 
11
 
 
22
  messages.append({"role": "question", "content": 질문})
23
  response = ""
24
 
25
+ chat_completion = client.chat.completions.create(
26
+ model="tgi",
27
+ messages=messages,
28
  stream=True,
29
+ max_tokens=max_tokens,
30
  temperature=temperature,
31
  top_p=top_p,
32
+ )
33
+
34
+ for message in chat_completion:
35
  token = message.choices[0].delta.content
36
 
37
  response += token
requirements.txt CHANGED
@@ -1 +1,2 @@
1
  huggingface_hub==0.22.2
 
 
1
  huggingface_hub==0.22.2
2
+ openai