Zack Saadioui
8/27/2024
1
2
bash
npm install apollo-server graphql1
2
3
4
5
6
7
8
9
10
11
type Model {
name: String!
size: Int
details: ModelDetails
}
type ModelDetails {
license: String
}
type Query {
models: [Model]
}1
🚀 Server ready at ${url}1
2
bash
ollama run llama21
114341
graphql-request1
2
bash
npm install axios1
http://localhost:11434/api/generate1
2
graphql
query { models { name size details { license } } }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
javascript
const resolvers = {
Query: {
models: async () => {
try {
const response = await axios.post(`http://localhost:11434/api/generate`, {
model: 'llama2',
prompt: 'Get list of models',
});
return response.data;
} catch (error) {
throw new Error(`Failed to fetch models: ${error.message}`);
}
},
},
};Copyright © Arsturn 2025