Skip to content

Commit

Permalink
add usage instruction and qianwen option to response
Browse files Browse the repository at this point in the history
  • Loading branch information
CassiusBlackX committed Jul 7, 2024
1 parent 6699b91 commit 7ed79df
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
this file is intended to recieve the audio from the user and then generate the response according to the audio
there are to options for generating the answer, one is using the self_deployed llama model, the other is using the api proveide by ali 通义千问
note that if the answer generated is not likely to be correct or even not generated, the program will inform the user its incapability
in consideration of time, we intend to response specific answer with pre_prepared audio, and the general answer with llama or 通义千问
"""

import os
import subprocess
import time
Expand Down Expand Up @@ -101,6 +109,33 @@ def close_websocket(client):
except Exception as e:
print('Error closing websocket:', e)

def generate_random_uint64():
# 生成一个无符号64位整数
random_uint64 = random.getrandbits(64)
return int(random_uint64)


def qianwen(input_question: str):
""" add another option for"""
dashscope.api_key = 'your_api_key'
resp = Generation.call(
model='qwen-v1',
prompt=input_question,
top_k=88.0,
top_p=0.8,
seed=int(generate_random_uint64() % 9223372036854775807)
)
# The response status_code is HTTPStatus.OK indicate success,
# otherwise indicate request is failed, you can get error code
# and message from code and message.
if resp.status_code == HTTPStatus.OK:
print(resp.output) # The output text
print(resp.usage) # The usage information
return resp.output.get("text")
else:
print(resp.code) # The error code.
print(resp.message) # The error message.
return None

class VoiceInteraction:
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
this is the very file that connect to the server and receive the warning type and finnaly give an answer to the user
"""
import socket
import threading
from recognize_generate4 import VoiceInteraction,establish_record_connection
Expand Down

0 comments on commit 7ed79df

Please sign in to comment.