Spaces:
Build error
Build error
test app
#2
by
chacha2525
- opened
- .gitignore +0 -46
- pyrightconfig.json +0 -4
- requirements.txt +3 -70
- src/llm.py +0 -44
.gitignore
DELETED
|
@@ -1,46 +0,0 @@
|
|
| 1 |
-
# Python virtual environments
|
| 2 |
-
.venv/
|
| 3 |
-
venv/
|
| 4 |
-
ENV/
|
| 5 |
-
env/
|
| 6 |
-
.env
|
| 7 |
-
|
| 8 |
-
# Python cache files
|
| 9 |
-
__pycache__/
|
| 10 |
-
*.py[cod]
|
| 11 |
-
*$py.class
|
| 12 |
-
*.so
|
| 13 |
-
.Python
|
| 14 |
-
build/
|
| 15 |
-
develop-eggs/
|
| 16 |
-
dist/
|
| 17 |
-
downloads/
|
| 18 |
-
eggs/
|
| 19 |
-
.eggs/
|
| 20 |
-
lib/
|
| 21 |
-
lib64/
|
| 22 |
-
parts/
|
| 23 |
-
sdist/
|
| 24 |
-
var/
|
| 25 |
-
wheels/
|
| 26 |
-
*.egg-info/
|
| 27 |
-
.installed.cfg
|
| 28 |
-
*.egg
|
| 29 |
-
|
| 30 |
-
# IDE specific files
|
| 31 |
-
.idea/
|
| 32 |
-
.vscode/
|
| 33 |
-
*.swp
|
| 34 |
-
*.swo
|
| 35 |
-
.DS_Store
|
| 36 |
-
|
| 37 |
-
# Jupyter Notebook
|
| 38 |
-
.ipynb_checkpoints
|
| 39 |
-
|
| 40 |
-
# Environment variables
|
| 41 |
-
.env
|
| 42 |
-
.env.local
|
| 43 |
-
.env.*.local
|
| 44 |
-
|
| 45 |
-
# Logs
|
| 46 |
-
*.log
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pyrightconfig.json
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"venvPath": ".",
|
| 3 |
-
"venv": ".venv"
|
| 4 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -1,70 +1,3 @@
|
|
| 1 |
-
altair
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
async-timeout==4.0.3
|
| 5 |
-
attrs==25.3.0
|
| 6 |
-
blinker==1.9.0
|
| 7 |
-
cachetools==5.5.2
|
| 8 |
-
certifi==2025.4.26
|
| 9 |
-
charset-normalizer==3.4.2
|
| 10 |
-
click==8.2.1
|
| 11 |
-
exceptiongroup==1.3.0
|
| 12 |
-
filetype==1.2.0
|
| 13 |
-
gitdb==4.0.12
|
| 14 |
-
gitpython==3.1.44
|
| 15 |
-
google-ai-generativelanguage==0.6.18
|
| 16 |
-
google-api-core==2.25.1
|
| 17 |
-
google-auth==2.40.3
|
| 18 |
-
googleapis-common-protos==1.70.0
|
| 19 |
-
grpcio==1.73.0
|
| 20 |
-
grpcio-status==1.73.0
|
| 21 |
-
h11==0.16.0
|
| 22 |
-
httpcore==1.0.9
|
| 23 |
-
httpx==0.28.1
|
| 24 |
-
idna==3.10
|
| 25 |
-
jinja2==3.1.6
|
| 26 |
-
jsonpatch==1.33
|
| 27 |
-
jsonpointer==3.0.0
|
| 28 |
-
jsonschema==4.24.0
|
| 29 |
-
jsonschema-specifications==2025.4.1
|
| 30 |
-
langchain==0.3.25
|
| 31 |
-
langchain-core==0.3.65
|
| 32 |
-
langchain-google-genai==2.1.5
|
| 33 |
-
langchain-text-splitters==0.3.8
|
| 34 |
-
langsmith==0.3.45
|
| 35 |
-
markupsafe==3.0.2
|
| 36 |
-
narwhals==1.42.1
|
| 37 |
-
numpy==2.2.6
|
| 38 |
-
orjson==3.10.18
|
| 39 |
-
packaging==24.2
|
| 40 |
-
pandas==2.3.0
|
| 41 |
-
pillow==11.2.1
|
| 42 |
-
proto-plus==1.26.1
|
| 43 |
-
protobuf==6.31.1
|
| 44 |
-
pyarrow==20.0.0
|
| 45 |
-
pyasn1==0.6.1
|
| 46 |
-
pyasn1-modules==0.4.2
|
| 47 |
-
pydantic==2.11.7
|
| 48 |
-
pydantic-core==2.33.2
|
| 49 |
-
pydeck==0.9.1
|
| 50 |
-
python-dateutil==2.9.0.post0
|
| 51 |
-
pytz==2025.2
|
| 52 |
-
pyyaml==6.0.2
|
| 53 |
-
referencing==0.36.2
|
| 54 |
-
requests==2.32.4
|
| 55 |
-
requests-toolbelt==1.0.0
|
| 56 |
-
rpds-py==0.25.1
|
| 57 |
-
rsa==4.9.1
|
| 58 |
-
six==1.17.0
|
| 59 |
-
smmap==5.0.2
|
| 60 |
-
sniffio==1.3.1
|
| 61 |
-
sqlalchemy==2.0.41
|
| 62 |
-
streamlit==1.45.1
|
| 63 |
-
tenacity==9.1.2
|
| 64 |
-
toml==0.10.2
|
| 65 |
-
tornado==6.5.1
|
| 66 |
-
typing-extensions==4.14.0
|
| 67 |
-
typing-inspection==0.4.1
|
| 68 |
-
tzdata==2025.2
|
| 69 |
-
urllib3==2.4.0
|
| 70 |
-
zstandard==0.23.0
|
|
|
|
| 1 |
+
altair
|
| 2 |
+
pandas
|
| 3 |
+
streamlit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/llm.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
import getpass
|
| 2 |
-
import os
|
| 3 |
-
from dotenv import load_dotenv
|
| 4 |
-
from pydantic import BaseModel, Field
|
| 5 |
-
from langchain.chat_models import init_chat_model
|
| 6 |
-
|
| 7 |
-
class GraspTarget(BaseModel):
|
| 8 |
-
"""Grasp target position for robot"""
|
| 9 |
-
# TODO: 需要根据实际的机器人坐标系进行调整, X coordinate in meters?
|
| 10 |
-
x: float = Field(description="x-axis coordinates in three-dimensional space")
|
| 11 |
-
y: float = Field(description="y-axis coordinates in three-dimensional space")
|
| 12 |
-
z: float = Field(description="z-axis coordinates in three-dimensional space")
|
| 13 |
-
|
| 14 |
-
class GraspTargetGenerator:
|
| 15 |
-
"""A class to generate grasp targets using LLM"""
|
| 16 |
-
|
| 17 |
-
def __init__(self, model_name: str = "gemini-2.0-flash", model_provider: str = "google_genai"):
|
| 18 |
-
"""Initialize the GraspTargetGenerator with specified model"""
|
| 19 |
-
# 加载环境变量
|
| 20 |
-
load_dotenv()
|
| 21 |
-
|
| 22 |
-
# 确保有 API key
|
| 23 |
-
if not os.environ.get("GOOGLE_API_KEY"):
|
| 24 |
-
os.environ["GOOGLE_API_KEY"] = getpass.getpass("Enter API key for Google Gemini: ")
|
| 25 |
-
|
| 26 |
-
# 初始化 LLM
|
| 27 |
-
self.llm = init_chat_model(model_name, model_provider=model_provider)
|
| 28 |
-
self.structured_llm = self.llm.with_structured_output(GraspTarget)
|
| 29 |
-
|
| 30 |
-
def generate_grasp_target(self, task_description: str) -> list[float]:
|
| 31 |
-
"""Generate grasp target coordinates based on task description
|
| 32 |
-
|
| 33 |
-
Args:
|
| 34 |
-
task_description: Description of the task to generate coordinates for
|
| 35 |
-
|
| 36 |
-
Returns:
|
| 37 |
-
List of [x, y, z] coordinates
|
| 38 |
-
"""
|
| 39 |
-
response = self.structured_llm.invoke(f"Task: {task_description}")
|
| 40 |
-
return [response.x, response.y, response.z]
|
| 41 |
-
|
| 42 |
-
if __name__ == "__main__":
|
| 43 |
-
generator = GraspTargetGenerator()
|
| 44 |
-
print(generator.generate_grasp_target("Pick up the red ball"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|