main
HuangHai 2 weeks ago
parent 95f88f867b
commit 0e3f2e77f0

@ -1,8 +1,9 @@
from Util.MySQLUtil import init_mysql_pool
from openai import OpenAI
from Config.Config import LLM_API_KEY, LLM_BASE_URL, LLM_MODEL_NAME
import asyncio
from Util.PostgreSQLUtil import init_postgres_pool
class QuestionMatcher:
def __init__(self):
@ -29,30 +30,27 @@ class QuestionMatcher:
async def main():
mysql_pool = await init_mysql_pool()
pg_pool = await init_postgres_pool()
matcher = QuestionMatcher()
async with mysql_pool.acquire() as conn:
await conn.ping()
async with conn.cursor() as cur:
await cur.execute("SELECT id, title,is_leaf FROM knowledge_points where is_leaf=1")
knowledge_points = await cur.fetchall()
questions = [
"小明有3个苹果又买了5个现在有多少个苹果",
"一个长方形的长是5cm宽是3cm面积是多少",
"小明的学校在小明家的东南方向150米处他每天中午都回家吃饭请问小明在上学和放学的路上一天一共走了多少米",
"兰兰家在学校的南面500米处方方家在兰兰家北面200米处请问学校在方方家什么方向的多少米处",
"小强的家门面向东,放学回家后站在门前,面向家门,他的前后左右分别是什么方向?",
"小明和小立背对背站立小明向北走150米小立向南走120米两人相距多远",
"1500棵树苗平均分给5个班种植每个班又将树苗平均分给5个小组每个小组分得多少棵树苗",
"粮店运来120吨大米第一天卖出总数的一半第二天卖出剩下的一半粮店还剩大米多少吨"
]
for question in questions:
match_result = await matcher.match_question_to_knowledge(question, knowledge_points)
print(f"题目: {question}")
print(f"匹配结果: {match_result}")
async with pg_pool.acquire() as conn:
# 执行查询
knowledge_points = await conn.fetch('SELECT id, title,is_leaf FROM knowledge_points where is_leaf=1')
questions = [
"小明有3个苹果又买了5个现在有多少个苹果",
"一个长方形的长是5cm宽是3cm面积是多少",
"小明的学校在小明家的东南方向150米处他每天中午都回家吃饭请问小明在上学和放学的路上一天一共走了多少米",
"兰兰家在学校的南面500米处方方家在兰兰家北面200米处请问学校在方方家什么方向的多少米处",
"小强的家门面向东,放学回家后站在门前,面向家门,他的前后左右分别是什么方向?",
"小明和小立背对背站立小明向北走150米小立向南走120米两人相距多远",
"1500棵树苗平均分给5个班种植每个班又将树苗平均分给5个小组每个小组分得多少棵树苗",
"粮店运来120吨大米第一天卖出总数的一半第二天卖出剩下的一半粮店还剩大米多少吨"
]
for question in questions:
match_result = await matcher.match_question_to_knowledge(question, knowledge_points)
print(f"题目: {question}")
print(f"匹配结果: {match_result}")
if __name__ == '__main__':

Loading…
Cancel
Save