Skip to content

Conversation

@AlextheYounga
Copy link
Contributor

This change adds a simple listModels() function to openai, ollama and anthropic. I believe I have followed your conventions to the letter, creating a new ListModelsJob class, a new test, and examples to show how to use this function. I have also updated the readme to show which clients support this new listModels function.

All tests are passing.

// openai-list-models.ts
import { openai } from "../src";

const job = openai().listModels();
const result = await job.run();

console.log(result);

I am using your library in another project of mine because it is useful and well-organized, but I needed this endpoint for these three clients.

@wangzuo
Copy link
Contributor

wangzuo commented Apr 1, 2025

Thank you for the PR! Model listing is definitely important. We will review this and add model listing support to the library.

@wangzuo
Copy link
Contributor

wangzuo commented Apr 1, 2025

Creating a new job for list models seems to heavy. We propose a more lightweight models() method available at https://github.com/modalityml/fluent-ai/pull/3/files. We would appreciate your feedback!

@AlextheYounga
Copy link
Contributor Author

AlextheYounga commented Apr 1, 2025

Hey, glad you like it! I get the instinct to keep it lightweight for a simple fetch — I felt the same. But I held back for a couple reasons:
1. Consistency – If every endpoint follows the same pattern, adding new ones becomes simple copy-paste. That might not matter now, but this project is well-written and could take off in popularity; consistency will really help avoid the kind of chaos that plagues many open source projects.
2. Future flexibility – OpenAI and Claude have variations like /models and /model with different params which the Job abstraction could handle. Allowing for that possibility now might seem like early optimization, but it’s also consistent with the rest of your code and sets you up for future needs.

Totally get it if you still prefer the lighter route — just wanted to share my thinking!

@wangzuo
Copy link
Contributor

wangzuo commented Apr 2, 2025

yes, you are right. Job api for consistency is a better approach. We'll work on a new release based on this PR including both models for listing and model for model detail if available from provider.

@wangzuo wangzuo merged commit 67a179a into modalityml:main Apr 2, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants