fix get_chat_records usage
This commit is contained in:
@@ -189,54 +189,67 @@ async def get_chat_records():
|
|||||||
|
|
||||||
print(f"Chat records:")
|
print(f"Chat records:")
|
||||||
for record in data['data']['list']:
|
for record in data['data']['list']:
|
||||||
print(f" - [{record['dataId']}] {record.get('content', {}).get('text', 'N/A')[:50]}...")
|
# Extract text from the value array structure
|
||||||
|
text = 'N/A'
|
||||||
|
value_array = record.get('value', [])
|
||||||
|
|
||||||
|
if value_array and len(value_array) > 0:
|
||||||
|
# Get the first item in the value array
|
||||||
|
first_item = value_array[0]
|
||||||
|
if first_item.get('type') == 'text' and 'text' in first_item:
|
||||||
|
text = first_item['text'].get('content', 'N/A')
|
||||||
|
|
||||||
|
# Get role (obj field: "Human" or "AI")
|
||||||
|
role = record.get('obj', 'Unknown')
|
||||||
|
|
||||||
|
print(f" - [{role}] [{record.get('dataId', 'N/A')}] {text[:50] if text != 'N/A' else 'N/A'}...")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error: {e}")
|
print(f"Error: {e}")
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
"""Run all examples."""
|
"""Run all examples."""
|
||||||
print("=== Simple Chat ===")
|
# print("=== Simple Chat ===")
|
||||||
try:
|
# try:
|
||||||
await simple_chat()
|
# await simple_chat()
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
print(f"Error: {e}")
|
# print(f"Error: {e}")
|
||||||
|
|
||||||
print("\n=== Streaming Chat ===")
|
# print("\n=== Streaming Chat ===")
|
||||||
try:
|
# try:
|
||||||
await streaming_chat()
|
# await streaming_chat()
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
print(f"Error: {e}")
|
# print(f"Error: {e}")
|
||||||
|
|
||||||
print("\n=== Chat with Context ===")
|
# print("\n=== Chat with Context ===")
|
||||||
try:
|
# try:
|
||||||
await chat_with_context()
|
# await chat_with_context()
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
print(f"Error: {e}")
|
# print(f"Error: {e}")
|
||||||
|
|
||||||
print("\n=== Get Histories ===")
|
# print("\n=== Get Histories ===")
|
||||||
try:
|
# try:
|
||||||
await get_histories()
|
# await get_histories()
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
print(f"Error: {e}")
|
# print(f"Error: {e}")
|
||||||
|
|
||||||
print("\n=== Get App Analytics ===")
|
# print("\n=== Get App Analytics ===")
|
||||||
try:
|
# try:
|
||||||
await get_app_analytics()
|
# await get_app_analytics()
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
print(f"Error: {e}")
|
# print(f"Error: {e}")
|
||||||
|
|
||||||
print("\n=== Multiple Requests (Concurrent) ===")
|
# print("\n=== Multiple Requests (Concurrent) ===")
|
||||||
try:
|
# try:
|
||||||
await multiple_requests()
|
# await multiple_requests()
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
print(f"Error: {e}")
|
# print(f"Error: {e}")
|
||||||
|
|
||||||
print("\n=== Chat with Variables ===")
|
# print("\n=== Chat with Variables ===")
|
||||||
try:
|
# try:
|
||||||
await chat_with_variables()
|
# await chat_with_variables()
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
print(f"Error: {e}")
|
# print(f"Error: {e}")
|
||||||
|
|
||||||
print("\n=== Get Chat Records ===")
|
print("\n=== Get Chat Records ===")
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user