alpiecode 0.9.6__tar.gz → 0.9.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {alpiecode-0.9.6 → alpiecode-0.9.7}/PKG-INFO +1 -1
- {alpiecode-0.9.6 → alpiecode-0.9.7}/pyproject.toml +1 -1
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/alpiecode.egg-info/PKG-INFO +1 -1
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/extension/alpiecode.vsix +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/server.py +77 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/README.md +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/setup.cfg +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/alpiecode.egg-info/SOURCES.txt +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/alpiecode.egg-info/dependency_links.txt +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/alpiecode.egg-info/entry_points.txt +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/alpiecode.egg-info/requires.txt +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/alpiecode.egg-info/top_level.txt +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/__init__.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/agent.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/backends/__init__.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/backends/base.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/backends/local_backend.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/backends/openai_backend.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/cache.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/cli.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/client.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/compaction.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/config.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/context.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/executor.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/github.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/guardian.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/local_model.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/media.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/memory.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/orchestrator.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/prompt.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/session.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/tools.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/updater.py +0 -0
- {alpiecode-0.9.6 → alpiecode-0.9.7}/src/codeagent/vscode_installer.py +0 -0
|
Binary file
|
|
@@ -177,6 +177,83 @@ if HAS_FASTAPI:
|
|
|
177
177
|
},
|
|
178
178
|
)
|
|
179
179
|
|
|
180
|
+
@app.post("/completion")
|
|
181
|
+
async def completion_endpoint(request: Request):
|
|
182
|
+
"""
|
|
183
|
+
Lightweight code completion for inline autocomplete.
|
|
184
|
+
|
|
185
|
+
Expects JSON: { prefix, suffix, language, file_path, max_tokens? }
|
|
186
|
+
Returns JSON: { completion }
|
|
187
|
+
"""
|
|
188
|
+
try:
|
|
189
|
+
body = await request.json()
|
|
190
|
+
except Exception:
|
|
191
|
+
raise HTTPException(status_code=400, detail="Invalid JSON body")
|
|
192
|
+
|
|
193
|
+
prefix = body.get("prefix", "")
|
|
194
|
+
suffix = body.get("suffix", "")
|
|
195
|
+
language = body.get("language", "")
|
|
196
|
+
file_path = body.get("file_path", "")
|
|
197
|
+
max_tokens = min(body.get("max_tokens", 128), 256)
|
|
198
|
+
|
|
199
|
+
if not prefix.strip():
|
|
200
|
+
return JSONResponse({"completion": ""})
|
|
201
|
+
|
|
202
|
+
# Build FIM prompt for code completion
|
|
203
|
+
fim_prompt = _build_fim_prompt(prefix, suffix, language, file_path)
|
|
204
|
+
|
|
205
|
+
import asyncio
|
|
206
|
+
|
|
207
|
+
def run_completion():
|
|
208
|
+
backend = app.state.backend
|
|
209
|
+
try:
|
|
210
|
+
resp = backend.chat_completion(
|
|
211
|
+
messages=[
|
|
212
|
+
{"role": "system", "content": "You are a code completion engine. Output ONLY the code that goes between the prefix and suffix. No explanations, no markdown, no backticks. Just raw code."},
|
|
213
|
+
{"role": "user", "content": fim_prompt},
|
|
214
|
+
],
|
|
215
|
+
tools=None,
|
|
216
|
+
temperature=0.0,
|
|
217
|
+
max_tokens=max_tokens,
|
|
218
|
+
enable_thinking=False,
|
|
219
|
+
)
|
|
220
|
+
completion = resp.content or ""
|
|
221
|
+
# Clean up: remove markdown fences if the model wraps output
|
|
222
|
+
completion = _clean_completion(completion)
|
|
223
|
+
return completion
|
|
224
|
+
except Exception as e:
|
|
225
|
+
return ""
|
|
226
|
+
|
|
227
|
+
completion = await asyncio.to_thread(run_completion)
|
|
228
|
+
return JSONResponse({"completion": completion})
|
|
229
|
+
|
|
230
|
+
def _build_fim_prompt(prefix: str, suffix: str, language: str, file_path: str) -> str:
|
|
231
|
+
"""Build a Fill-In-Middle prompt for code completion."""
|
|
232
|
+
lang_hint = f" ({language})" if language else ""
|
|
233
|
+
file_hint = f"\nFile: {file_path}" if file_path else ""
|
|
234
|
+
|
|
235
|
+
prompt = f"Complete the code{lang_hint}.{file_hint}\n\n"
|
|
236
|
+
prompt += f"Code before cursor:\n```\n{prefix[-2000:]}\n```\n\n"
|
|
237
|
+
if suffix.strip():
|
|
238
|
+
prompt += f"Code after cursor:\n```\n{suffix[:500]}\n```\n\n"
|
|
239
|
+
prompt += "Write ONLY the missing code that should appear at the cursor position. Output raw code only, no markdown."
|
|
240
|
+
return prompt
|
|
241
|
+
|
|
242
|
+
def _clean_completion(text: str) -> str:
|
|
243
|
+
"""Strip markdown fences and leading/trailing whitespace artifacts."""
|
|
244
|
+
text = text.strip()
|
|
245
|
+
# Remove ```language\n...\n``` wrappers
|
|
246
|
+
if text.startswith("```"):
|
|
247
|
+
lines = text.split("\n")
|
|
248
|
+
# Remove first line (```lang) and last line (```)
|
|
249
|
+
if len(lines) >= 3 and lines[-1].strip() == "```":
|
|
250
|
+
text = "\n".join(lines[1:-1])
|
|
251
|
+
elif len(lines) >= 2:
|
|
252
|
+
text = "\n".join(lines[1:])
|
|
253
|
+
if text.endswith("```"):
|
|
254
|
+
text = text[:-3].rstrip()
|
|
255
|
+
return text
|
|
256
|
+
|
|
180
257
|
@app.get("/metrics")
|
|
181
258
|
async def get_metrics():
|
|
182
259
|
"""Observability metrics."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|