Skip to content

Commit

Permalink
feat(python backend): function call upgrade (#368)
Browse files Browse the repository at this point in the history
* add function_call.py

* feat(backend): add wip annotation

* feat(backend): Synchronized Files

* feat(Backend): detect function call request

Changing few definations to fit OpenAI inference as new variables do not go well.
Implementing the detection of funcion call type request by the existance of tool attribute, as function call request need to be specifically processed.

* fix(Backend): detect function call request

Modifying request classification logics, as mistake flags are leading to  fault classification results.

* feat(Backend): Implement function call in non-stream mode for chatmode

- Add support for function calls in non-stream mode within the chatmode.
- Update relevant modules and functions to handle non-stream responses.
- Ensure compatibility with existing chatmode functionalities.

Commit footprint:
- Modify files: completion.py

* fix(Backend): Fix OpenAI API data format compatibility

Correct the data format to ensure compatibility with the OpenAI API.
Update relevant modules and functions in completion.py.

Details:
Modify files: completion.py

* feat(Backend): Implement non-streaming function call process

This commit includes the implementation of a non-streaming function call process. It covers the entire workflow for invoking functions in a single call. The code has been simply passed the functional tests, but the content still need to be improved.

Update relevant modules and functions in completion.py.

Details:
Modify files: completion.py
Modify functions: eval_rwkv, chat_template, chat_with_tools,

* fix(Backend): Move directory structure from routes to backend-python

I decided to move the directory structure from routes to backend-python because it aligns better with our project organization. This change won't impact existing functionality, but it will make the code clearer and easier to maintain.

Details:
Modify directory: tests
Modify files: function_call.py

* fix(Backend): Update Prompts to Mobius example and refactor code structure

Create postprocess_response function for text post-processing.
Restore function rwkv_eval.
Implement generation of tool_calls id.

Details:
Modify file(s): function_call.py

* test(Backend): Add postprocss_response.py for tests

Add a file to test the ability to evaluate postprocess_response functions and post-process string functions.

Details:
Add file(s): tests/postprocss_response.py

* fix(Backend): Fix OpenAI API data format compatibility

Correct the data format to ensure compatibility with the OpenAI API, according to OpenAI API Reference docs.
Update relevant modules and functions in completion.py.

Details:
Modify file(s): schema.py

* perf(Backend):  Modify some attributes.

Remove a data check field because it was already validated when it was passed in.
Fix attribute name "logprobs".

Details:
Modify file(s): completion.py

* fix(Backend): Fix postprocess_response funciton.

Modify the post-processing method of the string to match the inference results of the Mobius model.

Synchronously modify the test file.

Details:
Modify File(s): completion.py, postprocess_response.py

* refactor(Backend): Refactor two places related to prompt word synthesis.

Refactor the sinthesis method of append_message.
Refactor the sinthesis method of tools_text.

Details:
Modify File(s): completion.py

* 修正一些小细节使function_call工作正常

* test(Backend): Add function_call_stream.py

Add a file for testing server-side completion stream transmission.

Details:
Add file(s): tests/function_call_stream.py

* chore(Backend): Add a function to generate streaming responses for tool calls.

Create a draft of the stream_response_gen function, where I will implement generating a streaming function call later.

Details:
Modified File(s): completion.py

* fix(Backend): Adjust the output format of the streaming test file.

Adjust the print function.

The current streaming test is still a draft because it is now testing choices[0].delta.content instead of choices[0].delta.tool_calls.

Details:
Modifiy File(s): tests/function_call_stream.py

* feat(Backend): Try to implement streaming function calls

Add an asynchronous generator that handles function call requests. The generator passes the test of distinguishing the non-function call response that is produced in the result of the inference. However, the functionality associated with function calls has not been tested.

Details:
Modify File(s): completion.py

* style(Backend): Change some format

Use black formatter to change the code format, and these changes do not affect the operation of the code
Remove unnecessary library.

Details:
Modify File(s): completion.py

* stream function call细节调整

* docs(Backend): Modify comments in the code.

Modify the comments in the code to match the code content. This will not have an impact on functionality.

Details:
Modify File(s): completion.py

---------

Co-authored-by: josc146 <josStorer@outlook.com>
  • Loading branch information
EliwiiKeeya and josStorer committed Aug 27, 2024
1 parent fe53c86 commit 0080a1e
Show file tree
Hide file tree
Showing 5 changed files with 765 additions and 24 deletions.
Loading

0 comments on commit 0080a1e

Please sign in to comment.