DHEIVER commited on
Commit
a84fed4
·
verified ·
1 Parent(s): 6bd3626

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -16
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import gradio as gr
2
  from typing import List, Tuple
3
- import os
4
  from gradio_client import Client
5
 
6
  def create_chat_app():
@@ -13,11 +12,11 @@ def create_chat_app():
13
  top_p: float,
14
  ) -> str:
15
  """
16
- Process user message and generate a response using the Llama model.
17
  """
18
  try:
19
- # Initialize client for the specific space
20
- client = Client("1ofteamos/meta-llama-Llama-3.2-1B-Instruct")
21
 
22
  # Format the conversation history and current message
23
  formatted_message = f"{system_message}\n\nConversation history:\n"
@@ -29,9 +28,18 @@ def create_chat_app():
29
 
30
  formatted_message += f"User: {message}"
31
 
32
- # Get response from the model
 
 
 
 
 
 
33
  response = client.predict(
34
- message=formatted_message,
 
 
 
35
  api_name="/chat"
36
  )
37
 
@@ -43,9 +51,9 @@ def create_chat_app():
43
  # Interface configuration
44
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
45
  gr.Markdown("""
46
- # 🤖 Chat com Llama em Português
47
 
48
- Este é um chatbot baseado no modelo Llama. Para usar:
49
  1. Digite sua mensagem no campo abaixo
50
  2. Ajuste os parâmetros conforme necessário
51
  3. Pressione Enter para enviar
@@ -55,19 +63,19 @@ def create_chat_app():
55
  respond,
56
  additional_inputs=[
57
  gr.Textbox(
58
- value="Você é um assistente amigável e prestativo que responde em português.",
59
  label="Mensagem do Sistema"
60
  ),
61
  gr.Slider(
62
  minimum=1,
63
- maximum=2048,
64
- value=512,
65
  step=1,
66
  label="Máximo de Tokens"
67
  ),
68
  gr.Slider(
69
  minimum=0.1,
70
- maximum=4.0,
71
  value=0.7,
72
  step=0.1,
73
  label="Temperatura"
@@ -80,22 +88,24 @@ def create_chat_app():
80
  label="Top-p (Amostragem Nucleus)"
81
  ),
82
  ],
83
- title="Chat com Llama",
84
- description="Um chatbot interativo usando o modelo Llama.",
85
  examples=[
86
  ["Olá! Como você está?"],
87
  ["Pode me explicar o que é inteligência artificial?"],
88
- ["Qual é a capital do Brasil?"]
 
89
  ]
90
  )
91
 
92
  gr.Markdown("""
93
  ### ℹ️ Informações
94
- - Modelo: Llama 3.2 1B Instruct
95
  - Idioma: Português
96
  - Hospedagem: Hugging Face Spaces
97
 
98
  Para melhor desempenho, ajuste os parâmetros de acordo com suas necessidades.
 
99
  """)
100
 
101
  return demo
 
1
  import gradio as gr
2
  from typing import List, Tuple
 
3
  from gradio_client import Client
4
 
5
  def create_chat_app():
 
12
  top_p: float,
13
  ) -> str:
14
  """
15
+ Process user message and generate a response using the Llama 3.3 70B model.
16
  """
17
  try:
18
+ # Initialize client for the newer API
19
+ client = Client("aifeifei798/feifei-chat")
20
 
21
  # Format the conversation history and current message
22
  formatted_message = f"{system_message}\n\nConversation history:\n"
 
28
 
29
  formatted_message += f"User: {message}"
30
 
31
+ # Prepare the message payload
32
+ message_payload = {
33
+ "text": formatted_message,
34
+ "files": []
35
+ }
36
+
37
+ # Get response from the model with the specified parameters
38
  response = client.predict(
39
+ message=message_payload,
40
+ feifei_select=True,
41
+ additional_dropdown="meta-llama/Llama-3.3-70B-Instruct",
42
+ image_mod="pixtral",
43
  api_name="/chat"
44
  )
45
 
 
51
  # Interface configuration
52
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
53
  gr.Markdown("""
54
+ # 🤖 Chat com Llama 3.3 70B em Português
55
 
56
+ Este é um chatbot baseado no modelo Llama 3.3 70B. Para usar:
57
  1. Digite sua mensagem no campo abaixo
58
  2. Ajuste os parâmetros conforme necessário
59
  3. Pressione Enter para enviar
 
63
  respond,
64
  additional_inputs=[
65
  gr.Textbox(
66
+ value="Você é um assistente amigável e prestativo que responde em português. Você é baseado no modelo Llama 3.3 70B.",
67
  label="Mensagem do Sistema"
68
  ),
69
  gr.Slider(
70
  minimum=1,
71
+ maximum=4096,
72
+ value=2048,
73
  step=1,
74
  label="Máximo de Tokens"
75
  ),
76
  gr.Slider(
77
  minimum=0.1,
78
+ maximum=2.0,
79
  value=0.7,
80
  step=0.1,
81
  label="Temperatura"
 
88
  label="Top-p (Amostragem Nucleus)"
89
  ),
90
  ],
91
+ title="Chat com Llama 3.3 70B",
92
+ description="Um chatbot interativo usando o modelo Llama 3.3 70B Instruct.",
93
  examples=[
94
  ["Olá! Como você está?"],
95
  ["Pode me explicar o que é inteligência artificial?"],
96
+ ["Qual é a capital do Brasil?"],
97
+ ["Me ajude a escrever um código em Python para calcular fibonacci."]
98
  ]
99
  )
100
 
101
  gr.Markdown("""
102
  ### ℹ️ Informações
103
+ - Modelo: Llama 3.3 70B Instruct
104
  - Idioma: Português
105
  - Hospedagem: Hugging Face Spaces
106
 
107
  Para melhor desempenho, ajuste os parâmetros de acordo com suas necessidades.
108
+ Este modelo possui capacidades avançadas de processamento de linguagem natural.
109
  """)
110
 
111
  return demo