-
Notifications
You must be signed in to change notification settings - Fork 26
added the functionalities to let the user choose whether to overwrite… #3
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
Open
Weixuanf
wants to merge
2
commits into
main
Choose a base branch
from
feature/replace
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+192
−12
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -315,6 +315,74 @@ async def execute_tool(tool_call_id: str, tool_name: str, args_str: str, session | |
| router = APIRouter(prefix="/api") | ||
| @router.post("/chat") | ||
| async def chat(request: Request): | ||
| # data = await request.json() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里都删掉了是测试用的吗
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 对对对 |
||
| # messages = data.get('messages') | ||
| # session_id = data.get('session_id') | ||
| # provider = data.get('provider') | ||
| # url = data.get('url') | ||
| # if provider == 'ollama' and not url.endswith('/v1'): | ||
| # # openai compatible url | ||
| # url = url.rstrip("/") + "/v1" | ||
| # model = data.get('model') | ||
| # if model is None: | ||
| # raise HTTPException( | ||
| # status_code=400, # Bad Request | ||
| # detail="model is required" | ||
| # ) | ||
| # if provider is None: | ||
| # raise HTTPException( | ||
| # status_code=400, # Bad Request | ||
| # detail="provider is required" | ||
| # ) | ||
| # if session_id is None: | ||
| # raise HTTPException( | ||
| # status_code=400, # Bad Request | ||
| # detail="session_id is required" | ||
| # ) | ||
| # if len(messages) == 1: | ||
| # # create new session | ||
| # prompt = messages[0].get('content', '') | ||
| # await db_service.create_chat_session(session_id, model, provider, (prompt[:200] if isinstance(prompt, str) else '')) | ||
|
|
||
| # await db_service.create_message(session_id, messages[-1].get('role', 'user'), json.dumps(messages[-1])) if len(messages) > 0 else None | ||
| # # Create and store the chat task | ||
| # async def chat_loop(): | ||
| # cur_messages = messages | ||
|
|
||
| # try: | ||
| # if cur_messages[-1].get('role') == 'assistant' and cur_messages[-1].get('tool_calls') and \ | ||
| # cur_messages[-1]['tool_calls'][-1].get('function', {}).get('name') == 'finish': | ||
| # print('👇finish!') | ||
| # cur_messages.pop() | ||
| # await send_to_websocket(session_id, { | ||
| # 'type': 'all_messages', | ||
| # 'messages': cur_messages | ||
| # }) | ||
|
|
||
| # else: | ||
| # cur_messages = await chat_openai(cur_messages, session_id, model, provider, url) | ||
| # except Exception as e: | ||
| # print(f"Error in chat_loop: {e}") | ||
| # traceback.print_exc() | ||
| # await send_to_websocket(session_id, { | ||
| # 'type': 'error', | ||
| # 'error': str(e) | ||
| # }) | ||
|
|
||
| # await send_to_websocket(session_id, { | ||
| # 'type': 'done' | ||
| # }) | ||
|
|
||
| # task = asyncio.create_task(chat_loop()) | ||
| # stream_tasks[session_id] = task | ||
| # try: | ||
| # await task | ||
| # except asyncio.exceptions.CancelledError: | ||
| # print(f"🛑Session {session_id} cancelled during stream") | ||
| # finally: | ||
| # stream_tasks.pop(session_id, None) | ||
|
|
||
| # return {"status": "done"} | ||
| data = await request.json() | ||
| messages = data.get('messages') | ||
| session_id = data.get('session_id') | ||
|
|
@@ -383,6 +451,30 @@ async def chat_loop(): | |
| stream_tasks.pop(session_id, None) | ||
|
|
||
| return {"status": "done"} | ||
| # data = await request.json() | ||
| # session_id = data.get("session_id") | ||
|
|
||
| # # Simulate first chunk | ||
| # await send_to_websocket(session_id, { | ||
| # "type": "delta", | ||
| # "text": "Here is a backend-" | ||
| # }) | ||
|
|
||
| # # Simulate small delay between chunks (optional) | ||
| # await asyncio.sleep(1) | ||
|
|
||
| # # Simulate second chunk | ||
| # await send_to_websocket(session_id, { | ||
| # "type": "delta", | ||
| # "text": "generated assistant reply." | ||
| # }) | ||
|
|
||
| # # Mark the assistant message as complete | ||
| # await send_to_websocket(session_id, { | ||
| # "type": "done" | ||
| # }) | ||
|
|
||
| # return {"status": "done"} | ||
|
|
||
| async def send_to_websocket(session_id: str, event:dict): | ||
| ws = active_websockets.get(session_id) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个debounceUpdateFile()之后还是得加回来吧 这个是保存到磁盘上的file的
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那个setEditorContentWrapper我放到parent component里面了因为ChatInterface也需要,现在是个prop