Spaces:
Running
Running
class CustomOutputWrapper: | |
def handle_message_chat_completion(response): | |
message = {'content': ''} | |
try: | |
# handle dashscope response | |
if 'choices' not in response: | |
response = response['output'] | |
return response['choices'][0]['message'] | |
except Exception as e: | |
print(f'input: {response}, original error: {str(e)}') | |
return message | |
def handle_message_chat_completion_chunk(response): | |
message = {} | |
try: | |
return response['choices'][0]['delta']['content'] | |
except Exception as e: | |
print(f'input: {response}, original error: {str(e)}') | |
return message | |
def handle_message_text_completion(response): | |
message = '' | |
try: | |
message = response['output']['text'] | |
return message | |
except Exception as e: | |
print(f'input: {response}, original error: {str(e)}') | |
return message | |
DEFAULT_MESSAGE = { | |
'role': 'user', | |
'content': 'No entry from user - please suggest something to enter' | |
} | |