suayptalha commited on
Commit
890da26
·
verified ·
1 Parent(s): 428d9a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -1,11 +1,10 @@
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
3
  from gradio_client import Client, handle_file
4
 
5
- # Gradio Client
6
  client = Client("vikhyatk/moondream2")
7
 
8
- # Resmi tanımlayan fonksiyon
9
  def describe_image(image):
10
  result = client.predict(
11
  img=handle_file(image),
@@ -46,18 +45,15 @@ def respond(
46
  # Kullanıcı mesajını ekle
47
  messages.append({"role": "user", "content": message})
48
 
49
- response = ""
50
- # Modelden gelen yanıtı al ve döngüde token'ları birleştir
51
- for message in client.chat_completion(
52
- messages,
53
  max_tokens=max_tokens,
54
- stream=True,
55
  temperature=temperature,
56
- top_p=top_p,
57
- ):
58
- token = message.choices[0].delta.content
59
- response += token
60
- yield response
61
 
62
  # Gradio app arayüzünü oluştur
63
  demo = gr.Interface(
 
1
  import gradio as gr
 
2
  from gradio_client import Client, handle_file
3
 
4
+ # Gradio Client ile model yükle
5
  client = Client("vikhyatk/moondream2")
6
 
7
+ # Resim açıklamasını almak için kullanılacak fonksiyon
8
  def describe_image(image):
9
  result = client.predict(
10
  img=handle_file(image),
 
45
  # Kullanıcı mesajını ekle
46
  messages.append({"role": "user", "content": message})
47
 
48
+ # Modelden gelen yanıtı al
49
+ response = client.chat(
50
+ messages=messages,
 
51
  max_tokens=max_tokens,
 
52
  temperature=temperature,
53
+ top_p=top_p
54
+ )
55
+
56
+ return response['choices'][0]['message']['content']
 
57
 
58
  # Gradio app arayüzünü oluştur
59
  demo = gr.Interface(