peterpeter8585 commited on
Commit
aa6752e
1 Parent(s): 29b5f84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -1
app.py CHANGED
@@ -9,6 +9,36 @@ import transformers
9
  transformers.utils.move_cache()
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  def respond5(
13
  message,
14
  history: list[tuple[str, str]],
@@ -40,7 +70,6 @@ def respond5(
40
 
41
  response += token
42
  yield response
43
- password1=os.environ["password"]
44
  def respond4(
45
  message,
46
  history: list[tuple[str, str]],
@@ -427,6 +456,7 @@ ae= gr.ChatInterface(
427
  )
428
  aa=gr.ChatInterface(
429
  respond1,
 
430
  chatbot=chatbot3,
431
  additional_inputs=[
432
  gr.Textbox(value="You are a helpful assistant.", label="System message", interactive=True),
 
9
  transformers.utils.move_cache()
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
  import os
12
+ password1=os.environ["password"]
13
+ model_id = "peterpeter8585/ai2"
14
+ client2=InferenceClient("peterpeter8585/ai2")
15
+
16
+ def respond1(multimodal_input, history: list[tuple[str, str]],system_message,max_tokens,temperature,top_p,password):
17
+ if password==password1:
18
+
19
+ images = multimodal_input["files"]
20
+ content = [{"type": "image"} for _ in images]
21
+ content.append({"type": "text", "text": multimodal_input["text"]})
22
+ messages=[{"role":"system", "content":["type":"text", "text":"Your name is Chatchat.And, your made by SungYoon.In Korean, 정성윤.And these are the instructions:"+system_message]}]
23
+ messages.append([{"role": "user", "content": content}])
24
+ for val in history:
25
+ if val[1]:
26
+ messages.append({"role": "assistant", "content": ["type":"text", "text":val[1]]})
27
+ response = ""
28
+
29
+ for message in client2.chat_completion(
30
+ messages,
31
+ max_tokens=max_tokens,
32
+ stream=True,
33
+ temperature=temperature,
34
+ top_p=top_p,
35
+ ):
36
+ token = message
37
+ response += token
38
+ yield response
39
+
40
+
41
+
42
  def respond5(
43
  message,
44
  history: list[tuple[str, str]],
 
70
 
71
  response += token
72
  yield response
 
73
  def respond4(
74
  message,
75
  history: list[tuple[str, str]],
 
456
  )
457
  aa=gr.ChatInterface(
458
  respond1,
459
+ textbox=gr.MultimodalTextbox(file_types=["image"], show_label=False)
460
  chatbot=chatbot3,
461
  additional_inputs=[
462
  gr.Textbox(value="You are a helpful assistant.", label="System message", interactive=True),