Bryan Bimantaka (Monash University) commited on
Commit
fe7c49a
·
1 Parent(s): fe2b85b

Add gradio

Browse files
.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -1,53 +1,14 @@
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
-
10
- # def respond(
11
- # message,
12
- # history: list[tuple[str, str]],
13
- # system_message,
14
- # max_tokens,
15
- # temperature,
16
- # top_p,
17
- # ):
18
- # messages = [{"role": "system", "content": system_message}]
19
-
20
- # for val in history:
21
- # if val[0]:
22
- # messages.append({"role": "user", "content": val[0]})
23
- # if val[1]:
24
- # messages.append({"role": "assistant", "content": val[1]})
25
-
26
- # messages.append({"role": "user", "content": message})
27
-
28
- # response = ""
29
-
30
- # for message in client.chat_completion(
31
- # messages,
32
- # max_tokens=max_tokens,
33
- # stream=True,
34
- # temperature=temperature,
35
- # top_p=top_p,
36
- # ):
37
- # token = message.choices[0].delta.content
38
-
39
- # response += token
40
- # yield response
41
-
42
  from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
 
 
43
  import transformers
44
  from sentence_transformers import SentenceTransformer
45
  from datasets import Dataset, Features, Value, Sequence
46
  import pandas as pd
47
  import faiss
48
  import os
49
- from langchain.document_loaders import TextLoader
50
  import torch
 
51
 
52
  ST_MODEL = "LazarusNLP/all-indo-e5-small-v4"
53
  BASE_MODEL = "meta-llama/Meta-Llama-3.1-8B-Instruct"
@@ -146,18 +107,6 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
146
  demo = gr.ChatInterface(
147
  respond,
148
  textbox=gr.Textbox(placeholder="Enter message here", container=False, scale = 7),
149
- # additional_inputs=[
150
- # gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
151
- # gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
152
- # gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
153
- # gr.Slider(
154
- # minimum=0.1,
155
- # maximum=1.0,
156
- # value=0.95,
157
- # step=0.05,
158
- # label="Top-p (nucleus sampling)",
159
- # ),
160
- # ],
161
  )
162
 
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
2
+ from langchain_community.document_loaders import TextLoader # Diubah
3
+ from huggingface_hub import InferenceClient # Pastikan ini ada
4
  import transformers
5
  from sentence_transformers import SentenceTransformer
6
  from datasets import Dataset, Features, Value, Sequence
7
  import pandas as pd
8
  import faiss
9
  import os
 
10
  import torch
11
+ import gradio as gr
12
 
13
  ST_MODEL = "LazarusNLP/all-indo-e5-small-v4"
14
  BASE_MODEL = "meta-llama/Meta-Llama-3.1-8B-Instruct"
 
107
  demo = gr.ChatInterface(
108
  respond,
109
  textbox=gr.Textbox(placeholder="Enter message here", container=False, scale = 7),
 
 
 
 
 
 
 
 
 
 
 
 
110
  )
111
 
112
 
.ipynb_checkpoints/requirements-checkpoint.txt CHANGED
@@ -1 +1,10 @@
1
- huggingface_hub==0.22.2
 
 
 
 
 
 
 
 
 
 
1
+ huggingface_hub==0.22.2
2
+ transformers
3
+ torch
4
+ sentence-transformers
5
+ gradio
6
+ datasets
7
+ langchain
8
+ langchain-community
9
+ faiss-cpu
10
+ gradio
app.py CHANGED
@@ -8,6 +8,7 @@ import pandas as pd
8
  import faiss
9
  import os
10
  import torch
 
11
 
12
  ST_MODEL = "LazarusNLP/all-indo-e5-small-v4"
13
  BASE_MODEL = "meta-llama/Meta-Llama-3.1-8B-Instruct"
 
8
  import faiss
9
  import os
10
  import torch
11
+ import gradio as gr
12
 
13
  ST_MODEL = "LazarusNLP/all-indo-e5-small-v4"
14
  BASE_MODEL = "meta-llama/Meta-Llama-3.1-8B-Instruct"
requirements.txt CHANGED
@@ -7,3 +7,4 @@ datasets
7
  langchain
8
  langchain-community
9
  faiss-cpu
 
 
7
  langchain
8
  langchain-community
9
  faiss-cpu
10
+ gradio