julien-c HF staff Wauplin HF staff commited on
Commit
9b19366
1 Parent(s): 5e94338

Switch from `openai` to `huggingface_hub` (#1)

Browse files

- [WIP] Switch from `openai` to `huggingface_hub` (1d1463a56d97e530345417529e8cfd942df4b78c)
- Update app.py (974eb5442b813cefcd0ef9e72b45e42067da9002)


Co-authored-by: Lucain Pouget <Wauplin@users.noreply.huggingface.co>

Files changed (2) hide show
  1. app.py +2 -7
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,13 +1,9 @@
1
  import gradio as gr
2
- from openai import OpenAI
3
  import requests
4
  import huggingface_hub
5
 
6
  # Initialize the client, pointing it to one of the available models
7
- client = OpenAI(
8
- base_url="https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1/v1/",
9
- api_key=huggingface_hub.get_token(),
10
- )
11
 
12
 
13
  PROMPT = """
@@ -35,8 +31,7 @@ def generate(spaces):
35
 
36
  input = PROMPT + f"```py{app_py}```"
37
 
38
- chat_completion = client.chat.completions.create(
39
- model="mistralai/Mixtral-8x7B-Instruct-v0.1",
40
  messages=[
41
  {"role": "user", "content": input},
42
  ],
 
1
  import gradio as gr
 
2
  import requests
3
  import huggingface_hub
4
 
5
  # Initialize the client, pointing it to one of the available models
6
+ client = huggingface_hub.InferenceClient(model="mistralai/Mixtral-8x7B-Instruct-v0.1")
 
 
 
7
 
8
 
9
  PROMPT = """
 
31
 
32
  input = PROMPT + f"```py{app_py}```"
33
 
34
+ chat_completion = client.chat_completion(
 
35
  messages=[
36
  {"role": "user", "content": input},
37
  ],
requirements.txt CHANGED
@@ -1 +1 @@
1
- openai
 
1
+ git+https://github.com/huggingface/huggingface_hub