aidevhund commited on
Commit
661e3f4
·
verified ·
1 Parent(s): 8f31e52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -13,7 +13,7 @@ client = OpenAI(
13
  )
14
  print("OpenAI client initialized.")
15
 
16
- # Define a comprehensive system prompt
17
  SYSTEM_PROMPT = """
18
  You are a highly knowledgeable and reliable Crypto Trading Advisor and Analyzer.
19
  Your goal is to assist users in understanding, analyzing, and making informed decisions about cryptocurrency trading.
@@ -56,12 +56,13 @@ def respond(
56
  print(f"History: {history}")
57
 
58
  # Default values for the parameters
59
- max_tokens = 1024
60
- temperature = 0.3
61
  top_p = 0.95
62
  frequency_penalty = 0.0
63
  seed = None
64
 
 
65
  if "crypto" in message.lower():
66
  # Extract the cryptocurrency symbol from the message
67
  crypto_symbol = message.split()[0].upper() + "USDT" # Example: "Bitcoin" -> "BTCUSDT"
@@ -72,17 +73,19 @@ def respond(
72
  yield response
73
  return
74
 
75
- # Include real-time data in the system prompt
76
- SYSTEM_PROMPT += f"""
77
  Current Data for {crypto_symbol}:
78
  - Price: ${market_data['price']}
79
  - 24h Change: {market_data['change_24h']}%
80
  - Volume: {market_data['volume']}
81
  - Market Cap (proxy via quote volume): ${market_data['market_cap']}
82
  """
 
 
83
 
84
  # Prepare messages for the assistant
85
- messages = [{"role": "system", "content": SYSTEM_PROMPT}]
86
  for val in history:
87
  user_part = val[0]
88
  assistant_part = val[1]
 
13
  )
14
  print("OpenAI client initialized.")
15
 
16
+ # Define a comprehensive system prompt (global)
17
  SYSTEM_PROMPT = """
18
  You are a highly knowledgeable and reliable Crypto Trading Advisor and Analyzer.
19
  Your goal is to assist users in understanding, analyzing, and making informed decisions about cryptocurrency trading.
 
56
  print(f"History: {history}")
57
 
58
  # Default values for the parameters
59
+ max_tokens = 512
60
+ temperature = 0.7
61
  top_p = 0.95
62
  frequency_penalty = 0.0
63
  seed = None
64
 
65
+ # Check for cryptocurrency symbol in the message
66
  if "crypto" in message.lower():
67
  # Extract the cryptocurrency symbol from the message
68
  crypto_symbol = message.split()[0].upper() + "USDT" # Example: "Bitcoin" -> "BTCUSDT"
 
73
  yield response
74
  return
75
 
76
+ # Update the system prompt with real-time data
77
+ updated_prompt = SYSTEM_PROMPT + f"""
78
  Current Data for {crypto_symbol}:
79
  - Price: ${market_data['price']}
80
  - 24h Change: {market_data['change_24h']}%
81
  - Volume: {market_data['volume']}
82
  - Market Cap (proxy via quote volume): ${market_data['market_cap']}
83
  """
84
+ else:
85
+ updated_prompt = SYSTEM_PROMPT # Keep the original system prompt if no crypto-related message
86
 
87
  # Prepare messages for the assistant
88
+ messages = [{"role": "system", "content": updated_prompt}]
89
  for val in history:
90
  user_part = val[0]
91
  assistant_part = val[1]