Denyol commited on
Commit
607aecd
·
verified ·
1 Parent(s): db3001d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -1,10 +1,15 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
 
 
3
 
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
 
 
8
 
9
 
10
  def respond(
@@ -57,6 +62,16 @@ def respond(
57
 
58
  response = ""
59
 
 
 
 
 
 
 
 
 
 
 
60
  for message in client.chat_completion(
61
  messages,
62
  max_tokens=max_tokens,
@@ -68,6 +83,7 @@ def respond(
68
 
69
  response += token
70
  yield response
 
71
 
72
 
73
  """
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
+ import os
4
+ import cohere
5
 
6
  """
7
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
8
  """
9
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
10
+ COHERE_API_KEY = os.getenv("COHERE_API_KEY")
11
+ client_cohere = cohere.Client(COHERE_API_KEY)
12
+ COHERE_MODEL = "command-r-plus"
13
 
14
 
15
  def respond(
 
62
 
63
  response = ""
64
 
65
+ cohere_response = client_cohere.chat(
66
+ message=message,
67
+ model=COHERE_MODEL,
68
+ temperature=temperature,
69
+ max_tokens=max_tokens
70
+ )
71
+ response = cohere_response.text
72
+ yield response
73
+
74
+ '''
75
  for message in client.chat_completion(
76
  messages,
77
  max_tokens=max_tokens,
 
83
 
84
  response += token
85
  yield response
86
+ '''
87
 
88
 
89
  """