mirror of
https://github.com/katanemo/plano.git
synced 2026-04-25 16:56:24 +02:00
refactor demos (#398)
This commit is contained in:
parent
2bd61d628c
commit
b3c95a6698
93 changed files with 338 additions and 1042 deletions
9
demos/samples_python/stock_quote/README.md
Normal file
9
demos/samples_python/stock_quote/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
This demo shows how you can use a publicly hosted rest api that is protected by an access key.
|
||||
|
||||
Before you start the demo make sure you set `OPENAI_API_KEY` and `TWELVEDATA_API_KEY`.
|
||||
|
||||
To get `TWELVEDATA_API_KEY` please head over to https://twelvedata.com/.
|
||||
|
||||
Following screenshot shows interaction with stock quote demo,
|
||||
|
||||

|
||||
69
demos/samples_python/stock_quote/arch_config.yaml
Normal file
69
demos/samples_python/stock_quote/arch_config.yaml
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
version: v0.1
|
||||
|
||||
listener:
|
||||
address: 0.0.0.0
|
||||
port: 10000
|
||||
message_format: huggingface
|
||||
connect_timeout: 0.005s
|
||||
|
||||
llm_providers:
|
||||
- name: gpt-4o
|
||||
access_key: $OPENAI_API_KEY
|
||||
provider_interface: openai
|
||||
model: gpt-4o
|
||||
|
||||
endpoints:
|
||||
twelvedata_api:
|
||||
endpoint: api.twelvedata.com
|
||||
protocol: https
|
||||
|
||||
system_prompt: |
|
||||
You are a helpful assistant.
|
||||
|
||||
prompt_guards:
|
||||
input_guards:
|
||||
jailbreak:
|
||||
on_exception:
|
||||
message: Looks like you're curious about my abilities, but I can only provide assistance for currency exchange.
|
||||
|
||||
prompt_targets:
|
||||
- name: stock_quote
|
||||
description: get current stock exchange rate for a given symbol
|
||||
parameters:
|
||||
- name: symbol
|
||||
description: Stock symbol
|
||||
required: true
|
||||
type: str
|
||||
endpoint:
|
||||
name: twelvedata_api
|
||||
path: /quote
|
||||
http_headers:
|
||||
Authorization: "apikey $TWELVEDATA_API_KEY"
|
||||
system_prompt: |
|
||||
You are a helpful stock exchange assistant. You are given stock symbol along with its exchange rate in json format. Your task is to parse the data and present it in a human-readable format. Keep the details to highlevel and be concise.
|
||||
|
||||
- name: stock_quote_time_series
|
||||
description: get historical stock exchange rate for a given symbol
|
||||
parameters:
|
||||
- name: symbol
|
||||
description: Stock symbol
|
||||
required: true
|
||||
type: str
|
||||
- name: interval
|
||||
description: Time interval
|
||||
default: 1day
|
||||
enum:
|
||||
- 1h
|
||||
- 1day
|
||||
type: str
|
||||
endpoint:
|
||||
name: twelvedata_api
|
||||
path: /time_series
|
||||
http_headers:
|
||||
Authorization: "apikey $TWELVEDATA_API_KEY"
|
||||
system_prompt: |
|
||||
You are a helpful stock exchange assistant. You are given stock symbol along with its historical data in json format. Your task is to parse the data and present it in a human-readable format. Keep the details to highlevel only and be concise.
|
||||
|
||||
tracing:
|
||||
random_sampling: 100
|
||||
trace_arch_internal: true
|
||||
21
demos/samples_python/stock_quote/docker-compose.yaml
Normal file
21
demos/samples_python/stock_quote/docker-compose.yaml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
services:
|
||||
chatbot_ui:
|
||||
build:
|
||||
context: ../../shared/chatbot_ui
|
||||
ports:
|
||||
- "18080:8080"
|
||||
environment:
|
||||
# this is only because we are running the sample app in the same docker container environment as archgw
|
||||
- CHAT_COMPLETION_ENDPOINT=http://host.docker.internal:10000/v1
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
volumes:
|
||||
- ./arch_config.yaml:/app/arch_config.yaml
|
||||
|
||||
jaeger:
|
||||
build:
|
||||
context: ../../shared/jaeger
|
||||
ports:
|
||||
- "16686:16686"
|
||||
- "4317:4317"
|
||||
- "4318:4318"
|
||||
47
demos/samples_python/stock_quote/run_demo.sh
Normal file
47
demos/samples_python/stock_quote/run_demo.sh
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Function to start the demo
|
||||
start_demo() {
|
||||
# Step 1: Check if .env file exists
|
||||
if [ -f ".env" ]; then
|
||||
echo ".env file already exists. Skipping creation."
|
||||
else
|
||||
# Step 2: Create `.env` file and set OpenAI key
|
||||
if [ -z "$OPENAI_API_KEY" ]; then
|
||||
echo "Error: OPENAI_API_KEY environment variable is not set for the demo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Creating .env file..."
|
||||
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > .env
|
||||
echo ".env file created with OPENAI_API_KEY."
|
||||
fi
|
||||
|
||||
# Step 3: Start Arch
|
||||
echo "Starting Arch with arch_config.yaml..."
|
||||
archgw up arch_config.yaml
|
||||
|
||||
# Step 4: Start developer services
|
||||
echo "Starting Network Agent using Docker Compose..."
|
||||
docker compose up -d # Run in detached mode
|
||||
}
|
||||
|
||||
# Function to stop the demo
|
||||
stop_demo() {
|
||||
# Step 1: Stop Docker Compose services
|
||||
echo "Stopping Network Agent using Docker Compose..."
|
||||
docker compose down
|
||||
|
||||
# Step 2: Stop Arch
|
||||
echo "Stopping Arch..."
|
||||
archgw down
|
||||
}
|
||||
|
||||
# Main script logic
|
||||
if [ "$1" == "down" ]; then
|
||||
stop_demo
|
||||
else
|
||||
# Default action is to bring the demo up
|
||||
start_demo
|
||||
fi
|
||||
BIN
demos/samples_python/stock_quote/stock_quote_demo.png
Normal file
BIN
demos/samples_python/stock_quote/stock_quote_demo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 673 KiB |
Loading…
Add table
Add a link
Reference in a new issue