-
Notifications
You must be signed in to change notification settings - Fork 620
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
adding support for Anthropic, Cohere, Replicate, Azure #172
Conversation
This looks very interesting. Some questions:
In addition, token counting is a bit tricky. We need to list the number of tokens for each additional model (see pr_agent/algo/init.py). |
Hey @mrT23 Thanks for the feedback
Re: tokens, I'll make the required changes and update the PR - let's see if that works better. |
Preparing review... |
10 similar comments
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
PR Analysis
PR Feedback
|
Preparing review... |
5 similar comments
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
{
|
@mrT23 tested new version e2e and it works, please review and let me know if there's anything else i can do to help here. You can also test it with llama2 https://replicate.com/replicate/llama-2-70b-chat/api |
@krrishdholakia
So you can remove the prints. Other than that, PR looks very good. 👍 |
That's really cool! We shouldn't lose the ability to specify an openai org and use Azure openai though, it's being actively used. |
PR Analysis
PR Feedback
|
Preparing review... |
5 similar comments
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
Preparing review... |
PR Analysis
PR Feedback
|
Preparing review... |
PR Analysis
PR Feedback
|
PR Analysis
PR Feedback
|
PR Analysis
PR Feedback
|
@okotek @mrT23 tested using openai, azure and anthropic. To use a non-openai/azure providers,
A list of available models is available via code: import litellm
print(model_list) and also here:
We're also expecting to add support for PaLM models soon. |
@krrishdholakia @okotek I tested it with my deployment (Azure OpenAI + GitHub) and almost everything seems to be working as expected. ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/vcap/app/pr_agent/algo/git_patch_processing.py", line 206, in convert_to_hunks_with_lines_numbers
start1, size1, start2, size2 = map(int, match.groups()[:4])
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 428, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/fastapi/applications.py", line 290, in __call__
await super().__call__(scope, receive, send)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/starlette_context/middleware/raw_middleware.py", line 92, in __call__
await self.app(scope, receive, send_wrapper)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/fastapi/routing.py", line 241, in app
raw_response = await run_endpoint_function(
File "/home/vcap/deps/0/python/lib/python3.10/site-packages/fastapi/routing.py", line 167, in run_endpoint_function
return await dependant.call(**values)
File "/home/vcap/app/pr_agent/servers/github_app.py", line 37, in handle_github_webhooks
response = await handle_request(body, event=request.headers.get("X-GitHub-Event", None))
File "/home/vcap/app/pr_agent/servers/github_app.py", line 110, in handle_request
await agent.handle_request(api_url, comment_body)
File "/home/vcap/app/pr_agent/agent/pr_agent.py", line 72, in handle_request
await command2class[action](pr_url, args=args).run()
File "/home/vcap/app/pr_agent/tools/pr_code_suggestions.py", line 50, in run
await retry_with_fallback_models(self._prepare_prediction)
File "/home/vcap/app/pr_agent/algo/pr_processing.py", line 222, in retry_with_fallback_models
return await f(model)
File "/home/vcap/app/pr_agent/tools/pr_code_suggestions.py", line 62, in _prepare_prediction
self.patches_diff = get_pr_diff(self.git_provider,
File "/home/vcap/app/pr_agent/algo/pr_processing.py", line 58, in get_pr_diff
patches_extended, total_tokens = pr_generate_extended_diff(pr_languages, token_handler,
File "/home/vcap/app/pr_agent/algo/pr_processing.py", line 115, in pr_generate_extended_diff
full_extended_patch = convert_to_hunks_with_lines_numbers(extended_patch, file)
File "/home/vcap/app/pr_agent/algo/git_patch_processing.py", line 208, in convert_to_hunks_with_lines_numbers
start1, size1, size2 = map(int, match.groups()[:3])
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType' |
You're right, it's not related, we'll fix this. Edit: fixed |
@krrishdholakia thanks for your contributions, it works amazing |
@krrishdholakia Thanks a lot, litellm is really a great tool |
Thank you for the merge!! @mrT23 @okotek please let me know if there's any additional feedback
|
We've got extra eyes here.. I'll Need to fix asap |
@krrishdholakia does this support hugging face? I see litellm supports HF but when looking at the changes made in AiHandler I don't see you looking for |
Hey @dzlab we do support Huggingface, I can make a PR to enable support for that in Codium - any specific model you're trying to use? P.S.: we add new models + deployment platforms every day - announcements on Discord, feel free to join and see if any other providers make sense to add cc: @okotek / @mrT23 open to thoughts on how we could make it easier to add additional integrations |
HF have tons of models probably you don't want to explicitly add specific ones, no? In the AiHandler, it it can do something like Also, in [litellm]
# put here whatever key accepted by litellm
HF_KEY= if that sounds good, I can work on both PRs: one for litellm to add the config API, then one for pr-agent later |
Agreed - i guess i was asking since different models have different output styles see: BerriAI/litellm#87 We're slowly adding coverage for consistent output formats across models (doesn't block usage) - so if you had a specific one in mind, we can prioritize that |
adding support for Anthropic, Cohere, Replicate, Azure
Hi @mrT23 ,
Noticed you're calling just OpenAI. I'm working on litellm (simple library to standardize LLM API Calls - https://github.com/BerriAI/litellm) and was wondering if we could be helpful.
Added support for Anthropic, Llama2, Cohere by replacing the raw
openai.ChatCompletion.acreate
endpoint withacompletion
fromlitellm
.Would love to know if this helps.