Update docs/API_REFERENCE.md
Browse files- docs/API_REFERENCE.md +68 -0
docs/API_REFERENCE.md
CHANGED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# API Reference
|
2 |
+
|
3 |
+
This document describes the public Python modules and functions available in AnyCoder.
|
4 |
+
|
5 |
+
---
|
6 |
+
|
7 |
+
## `models.py`
|
8 |
+
|
9 |
+
### `ModelInfo` dataclass
|
10 |
+
|
11 |
+
```python
|
12 |
+
@dataclass
|
13 |
+
class ModelInfo:
|
14 |
+
name: str
|
15 |
+
id: str
|
16 |
+
description: str
|
17 |
+
default_provider: str = "auto"
|
18 |
+
```
|
19 |
+
|
20 |
+
### `AVAILABLE_MODELS: List[ModelInfo]`
|
21 |
+
|
22 |
+
A list of supported models with metadata.
|
23 |
+
|
24 |
+
### `find_model(identifier: str) -> Optional[ModelInfo]`
|
25 |
+
|
26 |
+
Lookup a model by name or ID. Returns a `ModelInfo` or `None`.
|
27 |
+
|
28 |
+
---
|
29 |
+
|
30 |
+
## `inference.py`
|
31 |
+
|
32 |
+
### `chat_completion(model_id: str, messages: List[Dict[str,str]], provider: Optional[str]=None, max_tokens: int=4096) -> str`
|
33 |
+
|
34 |
+
Send a one-shot chat completion request. Returns the assistant response as a string.
|
35 |
+
|
36 |
+
### `stream_chat_completion(model_id: str, messages: List[Dict[str,str]], provider: Optional[str]=None, max_tokens: int=4096) -> Generator[str]`
|
37 |
+
|
38 |
+
Stream partial generation results, yielding content chunks.
|
39 |
+
|
40 |
+
---
|
41 |
+
|
42 |
+
## `hf_client.py`
|
43 |
+
|
44 |
+
### `get_inference_client(model_id: str, provider: str="auto") -> InferenceClient`
|
45 |
+
|
46 |
+
Create and return a configured `InferenceClient`, routing to Groq, OpenAI, Gemini, Fireworks, or HF as needed.
|
47 |
+
|
48 |
+
---
|
49 |
+
|
50 |
+
## `deploy.py`
|
51 |
+
|
52 |
+
### `send_to_sandbox(code: str) -> str`
|
53 |
+
|
54 |
+
Wrap HTML code in a sandboxed iframe via a data URI for live preview.
|
55 |
+
|
56 |
+
### `load_project_from_url(url: str) -> Tuple[str, str]`
|
57 |
+
|
58 |
+
Import a Hugging Face Space by URL, returning status message and code content.
|
59 |
+
|
60 |
+
---
|
61 |
+
|
62 |
+
## `plugins.py`
|
63 |
+
|
64 |
+
### `PluginManager`
|
65 |
+
|
66 |
+
* `discover()`: auto-discovers plugins in the `plugins/` namespace.
|
67 |
+
* `list_plugins() -> List[str]`: return registered plugin names.
|
68 |
+
* `run_plugin(name: str, payload: Dict) -> Any`: execute a plugin action.
|