DazedMTLTool icon indicating copy to clipboard operation
DazedMTLTool copied to clipboard

cohere API

Open m5kro opened this issue 2 months ago • 5 comments

This adds the cohere API as an option instead of openai. There's only RPG mv/mz right now and it needs a lot more work to be as good as chatgpt.

A few things to note: The prompt definitely needs some fine-tuning as some/lots of lines are not being translated and it also needs to bypass the usage guidelines.

The free trial API has a limit of 10-20 requests per minute, there is a variable in the Python file for the delay between requests.

I only tried the command-r model, the commad-r-plus model may perform better.

Here are the test json files I used: data-ja.zip test-translate.zip <--output

Also here's an example response from the API: text='Sir Isaac Newton was born on December 25, 1642, in Woolsthorpe, Lincolnshire, England.' generation_id='681a5777-0947-4829-a7d7-f3d2aededc3d' citations=None documents=None is_search_required=None search_queries=None search_results=None finish_reason='COMPLETE' tool_calls=None chat_history=[ChatMessage(role='USER', message='Who discovered gravity?'), ChatMessage(role='SYSTEM', message='The man who is widely credited with discovering gravity is Sir Isaac Newton'), ChatMessage(role='USER', message='when was he born'), ChatMessage(role='CHATBOT', message='Sir Isaac Newton was born on December 25, 1642, in Woolsthorpe, Lincolnshire, England.')] meta=ApiMeta(api_version=ApiMetaApiVersion(version='1', is_deprecated=None, is_experimental=None), billed_units=ApiMetaBilledUnits(input_tokens=21, output_tokens=27, search_units=None, classifications=None), tokens=ApiMetaTokens(input_tokens=93, output_tokens=27), warnings=None) response_id='3201dc29-bf56-4b0f-93ce-9ec26ba35598'

m5kro avatar Apr 16 '24 05:04 m5kro

Hmm ideally I'd rather not have different modules for each translation engine that gets implemented since it will make maintaining them hell. Was there a challenge in integrating them into the current modules?

dazedanon avatar Apr 16 '24 15:04 dazedanon

It's acually really easy to implement the API since it is similar to the openai API. You can see which lines I changed here. The only reason I made it a different module was because I didn't want to accidentally break anything with the openai stuff.

m5kro avatar Apr 16 '24 17:04 m5kro

Ok, I think I've got it to work in the current module. Now it just looks in .env for which API type to use and the delay between requests. However, something is wrong with totalTokens and I have no idea what is causing it.

m5kro avatar Apr 16 '24 19:04 m5kro

Ok, I think I've got it to work in the current module. Now it just looks in .env for which API type to use and the delay between requests. However, something is wrong with totalTokens and I have no idea what is causing it.

What's wrong with totalTokens. Is it only for cohere or is happening on both.

dazedanon avatar Apr 16 '24 20:04 dazedanon

Nvm fixed it.

It's working like it did before.

m5kro avatar Apr 16 '24 21:04 m5kro

gonna close this for now as there seems to be no interest

m5kro avatar May 02 '24 05:05 m5kro

gonna close this for now as there seems to be no interest

Ah yes sorry slipped my mind. I don't plan on using this so lets leave it closed.

dazedanon avatar May 02 '24 05:05 dazedanon