-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from gomate-community/pipeline
支持es、monngo以及minio
- Loading branch information
Showing
22 changed files
with
1,849 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python | ||
# -*- coding:utf-8 _*- | ||
""" | ||
@author:quincy qiang | ||
@license: Apache Licence | ||
@file: bodys.py | ||
@time: 2024/06/13 | ||
@contact: yanqiangmiffy@gamil.com | ||
@software: PyCharm | ||
@description: coding.. | ||
""" | ||
from typing import List | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class RewriteBody(BaseModel): | ||
""" | ||
# 入参模型定义 | ||
""" | ||
query: str = Field("RCEP具体包括哪些国家", description="查询query") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python | ||
# -*- coding:utf-8 _*- | ||
""" | ||
@author:quincy qiang | ||
@license: Apache Licence | ||
@file: models.py | ||
@time: 2024/06/13 | ||
@contact: yanqiangmiffy@gamil.com | ||
@software: PyCharm | ||
@description: coding.. | ||
""" | ||
from pydantic import BaseModel | ||
from pydantic import Field | ||
from enum import IntEnum | ||
from tortoise import fields | ||
from apps.core.base import AbstractModel | ||
|
||
# class ApplicationModel(BaseModel): | ||
# application_name: str = Field("应用名称", description="应用名称") | ||
# knowledge_id: str = Field("应用名称", description="知识库结合id") | ||
# service_name: str = Field("官方体验服务", description="模型服务名称") | ||
# model_name: str = Field("GoGPT2.0", description="大模型名称") | ||
# temperature: float = Field(0.5, description="多样性大小") | ||
|
||
|
||
class Application(AbstractModel): | ||
application_name = fields.CharField(max_length=150, description="应用名称") | ||
knowledge_id = fields.IntField(default=1, description="知识库id") | ||
# knowledge_name=fields.CharField(max_length=150,description="知识库名称") | ||
# service_name = fields.CharField(max_length=150, description="模型服务名称") | ||
# model_name = fields.CharField(max_length=150, description="大模型名称") | ||
service_id=fields.IntField(default=1,description="模型服务id") | ||
model_id=fields.IntField(default=1,description="模型id") | ||
temperature = fields.FloatField(default=0.5, description="多样性大小") | ||
|
||
class Meta: | ||
table = "rag_application" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
# -*- coding:utf-8 _*- | ||
""" | ||
@author:quincy qiang | ||
@license: Apache Licence | ||
@file: views.py | ||
@time: 2024/06/13 | ||
@contact: yanqiangmiffy@gamil.com | ||
@software: PyCharm | ||
@description: coding.. | ||
""" | ||
import loguru | ||
from fastapi import APIRouter | ||
|
||
from api.apps.core.rewrite.bodys import RewriteBody | ||
from api.apps.handle.response.json_response import ApiResponse | ||
from gomate.modules.rewriter.openai_rewrite import OpenaiRewriter,OpenaiRewriterConfig | ||
|
||
|
||
rewriter_router = APIRouter() | ||
|
||
rewriter_config = OpenaiRewriterConfig( | ||
api_url="http://10.208.63.29:8888" | ||
) | ||
openai_rewriter = OpenaiRewriter(rewriter_config) | ||
|
||
# Create | ||
@rewriter_router.post("/rewrite/", response_model=None, summary="改写查询") | ||
async def rewrite(rewrite_body: RewriteBody): | ||
query = rewrite_body.query | ||
response = openai_rewriter.rewrite(query) | ||
return ApiResponse(response, message="改写查询") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import json | ||
|
||
import pandas as pd | ||
|
||
from gomate.modules.judger.chatgpt_judger import OpenaiJudger, OpenaiJudgerConfig | ||
|
||
if __name__ == '__main__': | ||
|
||
with open('citation.json', 'r', encoding="utf-8") as f: | ||
data = json.load(f) | ||
|
||
judger_config = OpenaiJudgerConfig( | ||
api_url="https://aicloud.oneainexus.cn:30013/inference/aicloud-yanqiang/gomatellm/" | ||
) | ||
openai_judger = OpenaiJudger(judger_config) | ||
|
||
documents = [ | ||
f"标题:{doc['newsinfo']['title']}\n日期:{doc['newsinfo']['date']}\n内容:{doc['newsinfo']['content']}\n" for doc | ||
in data['selected_docs'] | ||
] | ||
judge_docs = openai_judger.judge( | ||
query="在“一带一路”国际合作高峰论坛上,习近平讲了什么?", | ||
documents=documents, | ||
) | ||
# print(judge_docs) | ||
print(pd.DataFrame(judge_docs)) |
Oops, something went wrong.