Soulcre commited on
Commit
232147f
1 Parent(s): 78bf2dc

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: ChatbotAI
3
- emoji: 👀
4
- colorFrom: yellow
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 3.35.2
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: chatbotAI
3
+ app_file: app.py
 
 
4
  sdk: gradio
5
  sdk_version: 3.35.2
 
 
6
  ---
 
 
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from gpt_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
2
+ from langchain.chat_models import ChatOpenAI
3
+ import gradio as gr
4
+ import sys
5
+ import os
6
+
7
+ os.environ["OPENAI_API_KEY"] = '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'
8
+
9
+ def construct_index(directory_path):
10
+ max_input_size = 4096
11
+ num_outputs = 512
12
+ max_chunk_overlap = 20
13
+ chunk_size_limit = 600
14
+
15
+ prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
16
+
17
+ llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0.7, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
18
+
19
+ documents = SimpleDirectoryReader(directory_path).load_data()
20
+
21
+ index = GPTSimpleVectorIndex(documents, llm_predictor=llm_predictor, prompt_helper=prompt_helper)
22
+
23
+ index.save_to_disk('index.json')
24
+
25
+ return index
26
+
27
+ def chatbot(input_text):
28
+ index = GPTSimpleVectorIndex.load_from_disk('index.json')
29
+ response = index.query(input_text, response_mode="compact")
30
+ return response.response
31
+
32
+ iface = gr.Interface(fn=chatbot,
33
+ inputs=gr.components.Textbox(lines=7, label="Tulis disini"),
34
+ outputs="text",
35
+ title="Genie from PKBM Embun")
36
+
37
+ index = construct_index("docs")
38
+ iface.launch(share=True)
docs/LEGALITAS PKBM EMBUN.pdf ADDED
Binary file (258 kB). View file
 
docs/PKBM Embun 1.pdf ADDED
Binary file (227 kB). View file
 
docs/PKBM Embun 2.pdf ADDED
Binary file (393 kB). View file
 
docs/PKBM Embun 3.pdf ADDED
Binary file (231 kB). View file
 
docs/ijasah pkbm embun.pdf ADDED
Binary file (390 kB). View file
 
docs/tentang genie.pdf ADDED
Binary file (201 kB). View file
 
flagged/log.csv ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Tulis disini,output,flag,username,timestamp
2
+ Assalamualaikum,"'
3
+ Waalaikumsalam. Apa yang bisa saya bantu?",,,2023-06-16 18:42:43.986950
4
+ Apa itu pkbm,"'
5
+ PKBM adalah lembaga pendidikan nonformal yang diakui secara resmi oleh pemerintah. PKBM berperan penting dalam memberikan akses pendidikan kepada masyarakat yang tidak memiliki kesempatan untuk mengikuti pendidikan formal atau mengalami kesulitan dalam mengakses pendidikan tersebut. PKBM menyelenggarakan berbagai program pendidikan, mulai dari tingkat pendidikan anak usia dini, pendidikan dasar, hingga pendidikan menengah, dengan menggunakan metode yang sesuai dengan kebutuhan peserta didik.",,,2023-06-16 18:46:06.311091
6
+ cara buat nasi goreng,"'
7
+ Untuk membuat nasi goreng, Anda akan membutuhkan beras, minyak goreng, bawang merah, bawang putih, telur, daun bawang, dan bumbu-bumbu sesuai selera.
8
+
9
+ Langkah-langkahnya adalah sebagai berikut:
10
+ 1. Masak beras sampai matang.
11
+ 2. Panaskan minyak goreng dalam wajan.
12
+ 3. Tumis bawang merah dan bawang putih hingga harum.
13
+ 4. Masukkan telur dan aduk hingga matang.
14
+ 5. Masukkan beras yang sudah dimasak dan aduk hingga rata.
15
+ 6. Tambahkan daun bawang dan bumbu-bumbu sesuai selera.
16
+ 7. Aduk hingga semua bahan tercampur rata.
17
+ 8. Angkat dan sajikan.",,,2023-06-16 20:48:27.565308
index.json ADDED
The diff for this file is too large to render. See raw diff