Spaces:
Sleeping
Sleeping
Commit ·
74b53a1
0
Parent(s):
Update to use AdaptLLM/finance-chat model
Browse files- .gitattributes +35 -0
- README.md +26 -0
- app.py +72 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: PortfolioBuzz
|
| 3 |
+
emoji: 💰
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 5.42.0
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
hf_oauth: true
|
| 11 |
+
hf_oauth_scopes:
|
| 12 |
+
- inference-api
|
| 13 |
+
license: llama2
|
| 14 |
+
short_description: Finance AI Chatbot powered by AdaptLLM
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# 💰 PortfolioBuzz - Finance Chat
|
| 18 |
+
|
| 19 |
+
A finance-focused AI assistant powered by [AdaptLLM/finance-chat](https://huggingface.co/AdaptLLM/finance-chat), a domain-specific LLM based on LLaMA-2-Chat-7B.
|
| 20 |
+
|
| 21 |
+
## Features
|
| 22 |
+
- Expert financial advice and analysis
|
| 23 |
+
- Investment and market insights
|
| 24 |
+
- Financial planning guidance
|
| 25 |
+
|
| 26 |
+
Built with [Gradio](https://gradio.app) and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
|
app.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def respond(
|
| 6 |
+
message,
|
| 7 |
+
history: list[dict[str, str]],
|
| 8 |
+
system_message,
|
| 9 |
+
max_tokens,
|
| 10 |
+
temperature,
|
| 11 |
+
top_p,
|
| 12 |
+
hf_token: gr.OAuthToken,
|
| 13 |
+
):
|
| 14 |
+
"""
|
| 15 |
+
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
|
| 16 |
+
"""
|
| 17 |
+
client = InferenceClient(token=hf_token.token, model="AdaptLLM/finance-chat")
|
| 18 |
+
|
| 19 |
+
messages = [{"role": "system", "content": system_message}]
|
| 20 |
+
|
| 21 |
+
messages.extend(history)
|
| 22 |
+
|
| 23 |
+
messages.append({"role": "user", "content": message})
|
| 24 |
+
|
| 25 |
+
response = ""
|
| 26 |
+
|
| 27 |
+
for message in client.chat_completion(
|
| 28 |
+
messages,
|
| 29 |
+
max_tokens=max_tokens,
|
| 30 |
+
stream=True,
|
| 31 |
+
temperature=temperature,
|
| 32 |
+
top_p=top_p,
|
| 33 |
+
):
|
| 34 |
+
choices = message.choices
|
| 35 |
+
token = ""
|
| 36 |
+
if len(choices) and choices[0].delta.content:
|
| 37 |
+
token = choices[0].delta.content
|
| 38 |
+
|
| 39 |
+
response += token
|
| 40 |
+
yield response
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
"""
|
| 44 |
+
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 45 |
+
"""
|
| 46 |
+
chatbot = gr.ChatInterface(
|
| 47 |
+
respond,
|
| 48 |
+
type="messages",
|
| 49 |
+
title="💰 Finance Chat",
|
| 50 |
+
description="A finance-focused AI assistant powered by AdaptLLM/finance-chat. Ask questions about investments, markets, financial planning, and more!",
|
| 51 |
+
additional_inputs=[
|
| 52 |
+
gr.Textbox(value="You are an expert financial advisor and analyst. Provide helpful, accurate, and professional advice on finance, investments, markets, and economic topics. Always be clear about risks and encourage users to consult with certified professionals for major financial decisions.", label="System message"),
|
| 53 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 54 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 55 |
+
gr.Slider(
|
| 56 |
+
minimum=0.1,
|
| 57 |
+
maximum=1.0,
|
| 58 |
+
value=0.95,
|
| 59 |
+
step=0.05,
|
| 60 |
+
label="Top-p (nucleus sampling)",
|
| 61 |
+
),
|
| 62 |
+
],
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
with gr.Blocks() as demo:
|
| 66 |
+
with gr.Sidebar():
|
| 67 |
+
gr.LoginButton()
|
| 68 |
+
chatbot.render()
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
if __name__ == "__main__":
|
| 72 |
+
demo.launch()
|