chore(lint): add autofix-python (#907)
* chore(lint): add autofix-python * Update autofix-python.ymladd-prompt-lookup
parent
e92a8c8005
commit
316067cc53
|
|
@ -0,0 +1,31 @@
|
||||||
|
name: autofix.ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
paths:
|
||||||
|
- 'python/**'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
|
||||||
|
|
||||||
|
# If this is enabled it will cancel current running and start latest
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
autofix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- uses: chartboost/ruff-action@v1
|
||||||
|
with:
|
||||||
|
src: "./python"
|
||||||
|
args: --fix
|
||||||
|
|
||||||
|
- uses: autofix-ci/action@d3e591514b99d0fca6779455ff8338516663f7cc
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import modal
|
|
||||||
import os
|
import os
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
from collections import namedtuple
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from modal import Image, Mount, Secret, Stub, asgi_app, gpu, method
|
from modal import Image, Stub, gpu, method
|
||||||
from pathlib import Path
|
from typing import List, Optional, Tuple
|
||||||
from typing import Union, List, Optional, Any, Tuple
|
|
||||||
|
|
||||||
|
|
||||||
GPU_CONFIG = gpu.A10G()
|
GPU_CONFIG = gpu.A10G()
|
||||||
|
|
@ -61,7 +58,8 @@ class Model:
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
import socket
|
import socket
|
||||||
import subprocess, os
|
import subprocess
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from tabby_python_client import Client
|
from tabby_python_client import Client
|
||||||
|
|
@ -108,12 +106,11 @@ class Model:
|
||||||
|
|
||||||
@method()
|
@method()
|
||||||
async def complete(self, language: str, index: int, prompt: str) -> Tuple[int, Optional[str], Optional[str]]:
|
async def complete(self, language: str, index: int, prompt: str) -> Tuple[int, Optional[str], Optional[str]]:
|
||||||
|
from tabby_python_client import errors
|
||||||
from tabby_python_client.api.v1 import completion
|
from tabby_python_client.api.v1 import completion
|
||||||
from tabby_python_client.models import (
|
from tabby_python_client.models import (
|
||||||
CompletionRequest,
|
CompletionRequest,
|
||||||
DebugOptions,
|
DebugOptions,
|
||||||
CompletionResponse,
|
|
||||||
Segments,
|
|
||||||
)
|
)
|
||||||
from tabby_python_client.types import Response
|
from tabby_python_client.types import Response
|
||||||
|
|
||||||
|
|
@ -127,7 +124,7 @@ class Model:
|
||||||
client=self.client, json_body=request
|
client=self.client, json_body=request
|
||||||
)
|
)
|
||||||
|
|
||||||
if resp.parsed != None:
|
if resp.parsed is not None:
|
||||||
return index, resp.parsed.choices[0].text, None
|
return index, resp.parsed.choices[0].text, None
|
||||||
else:
|
else:
|
||||||
return index, None, f"<{resp.status_code}>"
|
return index, None, f"<{resp.status_code}>"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue