Spaces:
Build error
Build error
adding button for no one can use api key and have to set default
Browse files- README.md +5 -4
- app.py +16 -5
- image/bot_learning.png +0 -0
- image/chatbot.png +0 -0
- image/index_storage.png +0 -0
- image/set_api_key.png +0 -0
README.md
CHANGED
|
@@ -32,18 +32,19 @@ This project use Gradio to build User Interface, please use:
|
|
| 32 |
python app.py
|
| 33 |
```
|
| 34 |
Enjoy project with step by step follow this:
|
| 35 |
-
|
|
|
|
| 36 |
Bot Learning with URL
|
| 37 |
-
|
| 38 |
|
| 39 |
Please input URL and your file format and then press Training button, when the training process is finished, it's will notice you Training Completed
|
| 40 |
|
| 41 |
After that, you can starting chat with your custom bot about the topic in your URL
|
| 42 |
-
|
| 43 |
|
| 44 |
The vector index storage by this structure:
|
| 45 |
|
| 46 |
-
|
| 47 |
|
| 48 |
I've already adding the data from this page: https://www.presight.io/privacy-policy.html
|
| 49 |
You can check and chat with bot for Information in that or You can training more knowledge for it
|
|
|
|
| 32 |
python app.py
|
| 33 |
```
|
| 34 |
Enjoy project with step by step follow this:
|
| 35 |
+
First step, you need to set your openai api key right here:
|
| 36 |
+
!<img src='image/set_api_key.png'>
|
| 37 |
Bot Learning with URL
|
| 38 |
+
!<img src='image/bot_learning.png'>
|
| 39 |
|
| 40 |
Please input URL and your file format and then press Training button, when the training process is finished, it's will notice you Training Completed
|
| 41 |
|
| 42 |
After that, you can starting chat with your custom bot about the topic in your URL
|
| 43 |
+
!<img src='image/chatbot.png'>
|
| 44 |
|
| 45 |
The vector index storage by this structure:
|
| 46 |
|
| 47 |
+
!<img src='image/index_storage.png'>
|
| 48 |
|
| 49 |
I've already adding the data from this page: https://www.presight.io/privacy-policy.html
|
| 50 |
You can check and chat with bot for Information in that or You can training more knowledge for it
|
app.py
CHANGED
|
@@ -11,7 +11,12 @@ from langchain.chat_models import ChatOpenAI
|
|
| 11 |
from langchain.prompts import HumanMessagePromptTemplate
|
| 12 |
from langchain.schema import AIMessage, BaseMessage, HumanMessage, SystemMessage
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
human_message_prompt_template = HumanMessagePromptTemplate.from_template("{text}")
|
| 16 |
|
| 17 |
|
|
@@ -161,7 +166,15 @@ def main():
|
|
| 161 |
[system_prompt, model_name, temperature],
|
| 162 |
[chat, message, chatbot, messages],
|
| 163 |
)
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
with gr.Column():
|
| 166 |
system_prompt_area = gr.TextArea(
|
| 167 |
default_system_prompt, lines=4, label="prompt", interactive=True
|
|
@@ -184,6 +197,4 @@ def main():
|
|
| 184 |
if __name__ == '__main__':
|
| 185 |
demo = main()
|
| 186 |
demo.queue()
|
| 187 |
-
demo.launch()
|
| 188 |
-
|
| 189 |
-
|
|
|
|
| 11 |
from langchain.prompts import HumanMessagePromptTemplate
|
| 12 |
from langchain.schema import AIMessage, BaseMessage, HumanMessage, SystemMessage
|
| 13 |
|
| 14 |
+
|
| 15 |
+
def apply_api_key(api_key):
|
| 16 |
+
set_api_key(api_key=api_key)
|
| 17 |
+
return 'Successfully openai api key'
|
| 18 |
+
|
| 19 |
+
|
| 20 |
human_message_prompt_template = HumanMessagePromptTemplate.from_template("{text}")
|
| 21 |
|
| 22 |
|
|
|
|
| 166 |
[system_prompt, model_name, temperature],
|
| 167 |
[chat, message, chatbot, messages],
|
| 168 |
)
|
| 169 |
+
with gr.Column():
|
| 170 |
+
status = gr.Textbox(label='API KEY STATUS')
|
| 171 |
+
api_key_set = gr.Textbox(label='Set your OPENAI API KEY')
|
| 172 |
+
api_key_set_button = gr.Button("Set API key")
|
| 173 |
+
api_key_set_button.click(
|
| 174 |
+
apply_api_key,
|
| 175 |
+
[api_key_set],
|
| 176 |
+
[status]
|
| 177 |
+
)
|
| 178 |
with gr.Column():
|
| 179 |
system_prompt_area = gr.TextArea(
|
| 180 |
default_system_prompt, lines=4, label="prompt", interactive=True
|
|
|
|
| 197 |
if __name__ == '__main__':
|
| 198 |
demo = main()
|
| 199 |
demo.queue()
|
| 200 |
+
demo.launch(share=True)
|
|
|
|
|
|
image/bot_learning.png
ADDED
|
image/chatbot.png
ADDED
|
image/index_storage.png
ADDED
|
image/set_api_key.png
ADDED
|