Kevin Hu
		
	commited on
		
		
					Commit 
							
							·
						
						1dcb99c
	
1
								Parent(s):
							
							17c457d
								
add model types to factories API (#2341)
Browse files### What problem does this PR solve?
### Type of change
- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- api/apps/llm_app.py +12 -1
    	
        api/apps/llm_app.py
    CHANGED
    
    | @@ -29,7 +29,18 @@ import requests | |
| 29 | 
             
            def factories():
         | 
| 30 | 
             
                try:
         | 
| 31 | 
             
                    fac = LLMFactoriesService.get_all()
         | 
| 32 | 
            -
                     | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 33 | 
             
                except Exception as e:
         | 
| 34 | 
             
                    return server_error_response(e)
         | 
| 35 |  | 
|  | |
| 29 | 
             
            def factories():
         | 
| 30 | 
             
                try:
         | 
| 31 | 
             
                    fac = LLMFactoriesService.get_all()
         | 
| 32 | 
            +
                    fac = [f.to_dict() for f in fac if f.name not in ["Youdao", "FastEmbed", "BAAI"]]
         | 
| 33 | 
            +
                    llms = LLMService.get_all()
         | 
| 34 | 
            +
                    mdl_types = {}
         | 
| 35 | 
            +
                    for m in llms:
         | 
| 36 | 
            +
                        if m.status != StatusEnum.VALID.value:
         | 
| 37 | 
            +
                            continue
         | 
| 38 | 
            +
                        if m.fid not in mdl_types:
         | 
| 39 | 
            +
                            mdl_types[m.fid] = set([])
         | 
| 40 | 
            +
                        mdl_types[m.fid].add(m.model_type)
         | 
| 41 | 
            +
                    for f in fac:
         | 
| 42 | 
            +
                        f["model_types"] = list(mdl_types.get(f["name"], []))
         | 
| 43 | 
            +
                    return get_json_result(data=fac)
         | 
| 44 | 
             
                except Exception as e:
         | 
| 45 | 
             
                    return server_error_response(e)
         | 
| 46 |  |