zm-f21 commited on
Commit
11739c9
·
verified ·
1 Parent(s): 43b0358

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -1,9 +1,13 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
 
 
 
4
  import zipfile
5
  import os
6
 
 
7
  extract_folder = "yukon_texts"
8
 
9
  if not os.path.exists(extract_folder):
@@ -11,6 +15,27 @@ if not os.path.exists(extract_folder):
11
  zip_ref.extractall(extract_folder)
12
 
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  def respond(
15
  message,
16
  history: list[dict[str, str]],
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
+ from transformers import pipeline
5
+ import torch
6
+
7
  import zipfile
8
  import os
9
 
10
+
11
  extract_folder = "yukon_texts"
12
 
13
  if not os.path.exists(extract_folder):
 
15
  zip_ref.extractall(extract_folder)
16
 
17
 
18
+ llm = pipeline(
19
+ 'text-generation',
20
+ model='mistralai/Mistral-7B-Instruct-v0.2',
21
+ torch_dtype=torch.float16,
22
+ device_map="auto"
23
+ )
24
+
25
+ import gradio as gr
26
+
27
+ def chat(query):
28
+ return generate_with_rag(query)
29
+
30
+ iface = gr.Interface(
31
+ fn=chat,
32
+ inputs="text",
33
+ outputs="text",
34
+ title="Yukon Residential Tenancy Chatbot"
35
+ )
36
+ iface.launch()
37
+
38
+
39
  def respond(
40
  message,
41
  history: list[dict[str, str]],