Kush1 commited on
Commit
9ab9de8
·
1 Parent(s): c3c450e

Changes in app.py

Browse files
Files changed (2) hide show
  1. app.py +8 -21
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,15 +1,12 @@
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
- from transformers import AutoTokenizer, pipeline
10
-
11
- model_name = "glaiveai/Llama-3-8B-RAG-v1"
12
- tokenizer = AutoTokenizer.from_pretrained(model_name)
13
 
14
  # Example user query
15
  user_query = """Document:0
@@ -35,6 +32,9 @@ chat = [
35
  ]
36
 
37
 
 
 
 
38
  def respond(
39
  message,
40
  history: list[tuple[str, str]],
@@ -55,24 +55,11 @@ def respond(
55
  messages.append({"role": "system", "content": val[1]})
56
 
57
  messages.append({"role": "user", "content": message})
58
-
59
- response = ""
60
-
61
- prompt = tokenizer.apply_chat_template(messages, tokenize=False,add_generation_prompt=True)
62
- pipe = pipeline('text-generation', model= model_name, tokenizer=model_name, device=0)
63
- output = pipe(prompt,
64
- max_length=1000,
65
- num_return_sequences=1,
66
- top_k=50,
67
- top_p=top_p,
68
- temperature=temperature,
69
- do_sample=True,
70
- return_full_text=False
71
- )
72
 
73
- response = output[0]['generated_text']
74
 
75
- yield response
 
76
 
77
 
78
  # for message in client.chat_completion(
 
1
  import gradio as gr
2
+ import os
3
  from huggingface_hub import InferenceClient
4
+ import google.generativeai as genai
5
  """
6
  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
7
  """
8
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
9
 
 
 
 
 
10
 
11
  # Example user query
12
  user_query = """Document:0
 
32
  ]
33
 
34
 
35
+ genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
36
+
37
+ model = genai.GenerativeModel("gemini-pro-vision")
38
  def respond(
39
  message,
40
  history: list[tuple[str, str]],
 
55
  messages.append({"role": "system", "content": val[1]})
56
 
57
  messages.append({"role": "user", "content": message})
58
+ response = model.generate_content(messages)
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
 
60
 
61
+ print(response)
62
+ return response
63
 
64
 
65
  # for message in client.chat_completion(
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  huggingface_hub==0.22.2
2
  transformers
3
- torch
 
 
1
  huggingface_hub==0.22.2
2
  transformers
3
+ torch
4
+ google-generativeai