Spaces:
Sleeping
Sleeping
File size: 2,194 Bytes
cdb0bd0 9b2b06f cdb0bd0 0de40c5 cdb0bd0 0de40c5 cdb0bd0 0de40c5 cdb0bd0 0de40c5 cdb0bd0 0de40c5 e2453f8 0de40c5 e2453f8 0de40c5 e2453f8 0de40c5 e2453f8 6e61cbe 0de40c5 e2453f8 6e61cbe 0de40c5 e2453f8 0de40c5 e2453f8 0de40c5 e2453f8 0de40c5 e2453f8 6e61cbe e2453f8 0de40c5 cdb0bd0 db6b0dd 1e53d8e cdb0bd0 0de40c5 cdb0bd0 0de40c5 cdb0bd0 0de40c5 cdb0bd0 d2c20c9 0de40c5 6e83c24 0de40c5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | import json
from engine import UCGEngine,TOOLS
from groq import Groq
from components.ucg_g1 import UGC_GRAPH_1
client = Groq(api_key="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")
ucg_engine=UCGEngine(UGC_GRAPH_1,TOOLS)
#available_functions = {
# "UCGEngine":runner.run
#}
system='''
You are an assistant for the UGCEngine. Your task is:
- Take the user query , infer the Operation from Supported Operations along with their respective parameters
- Output exactly one JSON object with:
{{
"operation": "<Infered UGC operation name>",
"state": {{
... all required fields for the operation ...
}}
}}
- Do not add explanations , information or extra text.
- Only include required fields. Do not hallucinate.
Supported Operations:
NetworkResolver
Inputs:
- address (string)
InfuraRPC (eth address balances)
Inputs:
- address (string)
HeliusAPI (solana address balances)
Inputs:
address (string)
EthereumSigner
Inputs:
- address (string)
- payload (hex string)
SolanaSigner
Inputs:
- address (string)
- payload (hex string)
SolanaPayment
Inputs:
- address (string)
- to (string)
- amount (string)
Note: address not starting with 0x is solana address
'''
class UCGBRIDGE():
def __init__(self):
"""
ucg_engine: your existing UCGEngine instance
"""
self.engine=ucg_engine
def run_conversation(self,user_prompt):
"""Run a conversation with tool calling"""
messages = [
{
"role":"system",
"content":system
},
{
"role": "user",
"content": user_prompt,
}
]
#Step 1: Make initial API call
response = client.chat.completions.create(
model="moonshotai/kimi-k2-instruct-0905",
messages=messages,
)
response_message = response.choices[0].message.content
json_=json.loads(response_message)
print(response_message)
result =self.engine.run(json_["operation"],json_["state"])
return result
|