Skip to content

Created an api inference script with its supporting documentation#959

Merged
omaryashraf5 merged 4 commits into
meta-llama:mainfrom
omaryashraf5:api_inference
Jun 6, 2025
Merged

Created an api inference script with its supporting documentation#959
omaryashraf5 merged 4 commits into
meta-llama:mainfrom
omaryashraf5:api_inference

Conversation

@omaryashraf5

Copy link
Copy Markdown
Contributor

Created an API inference script where users could pick a llama model, set their api keys, prompt the model and see the results on a Gradio UI.

Tested the system and attached a snap shot of the UI in action.
Screenshot 2025-05-29 at 7 20 42 PM

@albertodepaola albertodepaola left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for putting this together! Overall looks good, added a couple of comments on the args to the script.

if api_key is not None:
os.environ["LLAMA_API_KEY"] = api_key
else:
env_var_name = f"{args.provider.upper()}_API_KEY"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The provider param seems to be missing from the parser and the docs. We should document how this can be used to change the env variable lookup. Having said that, these other providers might not be compatible with LlamaAPIClient. The options would be to use OpenAI compatible layer in Llama API (https://llama.developer.meta.com/docs/features/compatibility/?team_id=465615129850692) or remove this alternative.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @albertodepaola for noticing that! I have added the provider argument back. I have only included Llama and OpenAI. Please let me know what you think!

)
args = parser.parse_args()

api_key: Optional[str] = args.api_key

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: add the import to the top of the file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @albertodepaola Which import?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Gotcha! I added info about that in the README

- Passed the API key using the `--api-key` argument
- Set the appropriate environment variable

### Known Issues

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When fixing the comments below, this will become irrelevant, remove or update accordingly!

@albertodepaola albertodepaola left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LG, thanks for addressing the comments!

@omaryashraf5
omaryashraf5 merged commit ddd7429 into meta-llama:main Jun 6, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants