Spaces:
Runtime error
Runtime error
File size: 849 Bytes
2fe4e9d 532a759 2fe4e9d ea3c0cf 2fe4e9d 532a759 2fe4e9d ea3c0cf 2fe4e9d e34be6c ea3c0cf 2fe4e9d | 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 | import json
import logging
from fastapi.encoders import jsonable_encoder
from edu_assistant.learning_tasks import QaTask
from edu_assistant.utils.common_utils import init_local_logging
init_local_logging(logging.DEBUG)
instruction = """
Act as a c++ professional to answer student aged 5-10 questions. Answer properly and politely.
"""
task = QaTask(instruction=instruction)
def qa_once():
result = task.ask("请问什么是指针?", session=False)
print(json.dumps(jsonable_encoder(result), ensure_ascii=False, indent=4))
def qa_twice():
task = QaTask()
result = task.ask("请问如何释放一个数组?")
result = task.ask("那指针呢?", session_id=result["session_id"])
print(json.dumps(jsonable_encoder(result), ensure_ascii=False, indent=4))
if __name__ == "__main__":
# qa_once()
qa_twice()
|