Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add web api for /spec-repair/ #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tzing0013
Copy link

1.there's two commits, separate them to distinguish the code change for specrepair code
2.fix error for for service startup, No module named 'infra_ai_service', http connection refused
3.change specrepair code for fast API
4.change api router prefix to /api/v1

@@ -2,7 +2,7 @@
from fastapi import HTTPException
import logging

from infra_ai_service.model.model import TextOutput
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infra_ai_service 不要去掉,执行前先 pip install .

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -2,7 +2,7 @@
from fastapi import HTTPException
import logging

from infra_ai_service.model.model import TextOutput
from model.model import TextOutput

logger = logging.getLogger(__name__)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
将代码行覆盖率改为50,补充UT

@@ -1,10 +1,10 @@
from fastapi import APIRouter

from infra_ai_service.api.ai_enhance.text_process import TextInput
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不去掉包名,本地执行前先 pip install .

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样可以方便后面写UT测试用例

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

try:
messages = self._prepare_messages_pro_1(spec, log, doc_content)
response = self.client.chat.completions.create(
model="claude-3-5-sonnet-20240620", messages=messages
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

模型名字不要在代码里写死,做到配置文件中可以配置

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

api_key = os.getenv("OPENAI_API_KEY", None)
base_url = os.getenv("OPENAI_BASE_URL", None)
self.client = OpenAI(api_key=api_key, base_url=base_url)
self.model = "gpt-4-0613"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

模型不要在代码中写死

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

class SpecBot:
def __init__(self):
api_key = os.getenv("OPENAI_API_KEY", None)
base_url = os.getenv("OPENAI_BASE_URL", None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API_KEY 和 BASE_URL 做到可配置

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants