jhansi1 commited on
Commit
533bf8f
·
verified ·
1 Parent(s): 3534478

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -3,10 +3,10 @@ from huggingface_hub import InferenceClient
3
  from transformers import pipeline
4
  from typing import List, Tuple # Importing for type annotations
5
 
6
- # Initialize InferenceClient with the correct model
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
9
- # Function to handle the response generation using chat completion
10
  def respond(
11
  message: str,
12
  history: List[Tuple[str, str]], # Using List and Tuple for type annotation
@@ -29,17 +29,14 @@ def respond(
29
 
30
  response = ""
31
 
32
- # Use the client to get chat completion and stream the response
33
- for message in client.chat_completion(
34
- messages,
35
- max_tokens=max_tokens,
36
- stream=True,
37
- temperature=temperature,
38
- top_p=top_p,
39
- ):
40
- token = message.choices[0].delta.content
41
- response += token
42
- yield response
43
 
44
 
45
  # Setting up Gradio Interface
 
3
  from transformers import pipeline
4
  from typing import List, Tuple # Importing for type annotations
5
 
6
+ # Initialize the BERT model pipeline for the "fill-mask" task
7
+ pipe = pipeline("fill-mask", model="bert-base-uncased")
8
 
9
+ # Function to handle the response generation using BERT
10
  def respond(
11
  message: str,
12
  history: List[Tuple[str, str]], # Using List and Tuple for type annotation
 
29
 
30
  response = ""
31
 
32
+ # Using the BERT pipeline to fill the mask (this is different from the GPT-style completion)
33
+ # BERT doesn't generate text the same way, so we are simulating a response for this demo
34
+ result = pipe(f"Hello, how are you today? {message} [MASK]")
35
+
36
+ # Collecting the filled-in mask (likely output from BERT's "fill-mask" task)
37
+ response = result[0]['sequence']
38
+
39
+ yield response
 
 
 
40
 
41
 
42
  # Setting up Gradio Interface