Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update examples/semiconductor #340

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
69d0dd7
add expert plans and knowledge for 1 demo question
srag21 Aug 7, 2024
892e29c
update examples/semiconductor/streamlit-main DEFAULT_PROBLEM
TheVinhLuong102 Aug 7, 2024
81af153
simplify examples/semiconductor/streamlit-main app
TheVinhLuong102 Aug 7, 2024
d22627b
update api
Aug 7, 2024
9e3e91b
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
Aug 7, 2024
a77f18e
update examles/semiconductor/expert-knowledge.txt
TheVinhLuong102 Aug 7, 2024
9488a16
Merge pull request #341 from aitomatic/examples/semicon-optim
TheVinhLuong102 Aug 7, 2024
db8a06c
update new plan
Aug 7, 2024
3476219
feat: semiconductor ui
vophihungvn Aug 7, 2024
1f7a6ce
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
vophihungvn Aug 7, 2024
d4f34b1
parse json
Aug 7, 2024
8c12a4d
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
Aug 7, 2024
73946a5
feat: setup app stack
vophihungvn Aug 7, 2024
e95ed97
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
vophihungvn Aug 7, 2024
b167f2d
feat: move to component files
vophihungvn Aug 7, 2024
bee7bd4
fix: updated Dockerfile
vophihungvn Aug 7, 2024
60a3ddd
feat: add package json fie
vophihungvn Aug 7, 2024
1aff6cf
update api
Aug 7, 2024
fbe1b11
feat: add env file
vophihungvn Aug 7, 2024
7f355a4
handle bugs
Aug 7, 2024
c181aa8
feat: integrate backend
vophihungvn Aug 7, 2024
4fd14e1
Merge branch 'examples/semiconductor' of github.com:aitomatic/openssa…
vophihungvn Aug 7, 2024
8392ec1
feat: integrate api
vophihungvn Aug 7, 2024
a4e3040
feat: refactor right pane
vophihungvn Aug 7, 2024
558dff6
feat: Add agent advice
vophihungvn Aug 7, 2024
36ada5a
feat: updated UI
vophihungvn Aug 8, 2024
e4e731c
fix typos
Aug 8, 2024
92330eb
fix placeholder
Aug 8, 2024
d8d787c
update examples/semiconductor/streamlit-main
TheVinhLuong102 Aug 10, 2024
16b9c3d
refactor examples/semiconductor/streamlit-main app
TheVinhLuong102 Aug 10, 2024
050f5b3
update examples/semiconductor/streamlit-main app
TheVinhLuong102 Aug 10, 2024
e90354a
feat: log time
vophihungvn Aug 12, 2024
302d9ce
minor edit in examples/semiconductor/agent module imports
TheVinhLuong102 Aug 13, 2024
97a4686
Merge branch 'main' of https://GitHub.com/Aitomatic/OpenSSA into exam…
TheVinhLuong102 Aug 30, 2024
96e81e5
feat: new UI
vophihungvn Sep 3, 2024
dbcb28a
fix: image width
vophihungvn Sep 3, 2024
72c4fa0
feat: response
vophihungvn Sep 5, 2024
fdba0d0
fix: get response from backend
vophihungvn Sep 5, 2024
b9fcf26
Merge branch 'main' of https://GitHub.com/Aitomatic/OpenSSA into exam…
TheVinhLuong102 Oct 1, 2024
f9204bb
Merge branch 'main' of https://GitHub.com/Aitomatic/OpenSSA into exam…
TheVinhLuong102 Oct 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ docs/_build/
# DATA & EXAMPLE FILES
# ====================
examples/**/*.json
!examples/**/package.json
!examples/**/package-lock.json

.openssa/
test*.ipynb
tmp/
4 changes: 2 additions & 2 deletions examples/semiconductor/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from openssa import Agent, ProgramSpace, HTP, HTPlanner, OpenAILM

# pylint: disable=wrong-import-order
from data_and_knowledge import EXPERT_PROGRAM_SPACE
from data_and_knowledge import EXPERT_PROGRAM_SPACE, EXPERT_KNOWLEDGE
from semikong_lm import SemiKongLM


Expand All @@ -22,7 +22,7 @@ def get_or_create_agent(use_semikong_lm: bool = True, max_depth=2, max_subtasks_

return Agent(program_space=program_space,
programmer=HTPlanner(lm=lm, max_depth=max_depth, max_subtasks_per_decomp=max_subtasks_per_decomp),
knowledge={},
knowledge={EXPERT_KNOWLEDGE} if EXPERT_KNOWLEDGE else None,
resources={})


Expand Down
11 changes: 11 additions & 0 deletions examples/semiconductor/data_and_knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
load_dotenv()


EXPERT_KNOWLEDGE_FILE_PATH: Path = Path(__file__).parent / 'expert-knowledge.txt'
with open(file=EXPERT_KNOWLEDGE_FILE_PATH,
buffering=-1,
encoding='utf-8',
errors='strict',
newline=None,
closefd=True,
opener=None) as f:
EXPERT_KNOWLEDGE: str = f.read()


EXPERT_PROGRAM_SPACE_FILE_PATH: Path = Path(__file__).parent / 'expert-program-space.yml'
with open(file=EXPERT_PROGRAM_SPACE_FILE_PATH,
buffering=-1,
Expand Down
62 changes: 62 additions & 0 deletions examples/semiconductor/expert-knowledge.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Etching Silicon Dioxide (SiO2): typical recipe(s)
=================================================

If using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE)
--------------------------------------------------------------------


GASES & FLOW RATES:

Common gas is CHF3, often mixed with small amount of Ar and/or O2:
- CHF3 provides fluorine for etching while also polymerising to provide sidewall protection, improving anisotropy
- Ar helps maintain stable plasma
- O2 enhances volatility of etch products

Typical starting point:
- 20-50 sccm of CHF3
- 5-10 sccm of Ar
- 2-5 sccm of O2


ICP POWER:

Higher ICP power (e.g., 500-1000W) increases plasma density and etch rate
BUT may also lead to more physical damage and less anisotropic profiles


RF POWER:

Lower RF power (e.g., 10-50W) provides more anisotropic profiles


PRESSURE:

Lower pressure (e.g., 5-20 mTorr) helps improve anisotropy


ETCH TIME:

You need to adjust etch time depending on desired depth and etch rate.

Remember that etch rate can vary across wafer and over time, so it's best to overestimate time and measure depth periodically.


END-POINT DETECTION:

Many RIE systems have optical emission spectroscopy (OES) or interferometry for end-point detection.
These can stop etching process when desired depth is reached.


OPTIMIZATION CONSIDERATIONS:

- Etch rate
- Selectivity to mask and underlying layers
- Etch profile (anisotropy)
- Uniformity
- Physical or chemical damage


SAFETY PROCEDURES:

- Always follow safety procedures when working with plasma etching systems and handling gases
- Confirm with facility and equipment manager that your planned recipe is compatible and won't cause any damage or contamination
17 changes: 17 additions & 0 deletions examples/semiconductor/expert-program-space.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plan:
task: |-
For etching PECVD SiO2 using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE),
recommend 2 good parameter sets and their relative advantages/disadvantages

sub-htps:
- task: |-
Get typical gases used for such process and their flow rate ranges
in SiO2 etching using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE)

- task: |-
Get typical ICP Power, RF Power and Pressure value ranges and associated trade-offs
in SiO2 etching using Inductively Coupled Plasma (ICP) Reactive Ion Etching (RIE)

- task: |-
Recommend 2 parameter sets (each including Flow Rate for each Gas, plus ICP Power, RF Power and Pressure)
with analysis of their relative pros and cons.
39 changes: 39 additions & 0 deletions examples/semiconductor/semiconductor-ui/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM --platform=linux/amd64 python:3.10-slim AS base

# Install Poetry
RUN apt update -y && apt install poppler-utils -y
RUN python -m pip install --upgrade pip && \
pip install --no-cache-dir poetry==1.3.2


RUN poetry config virtualenvs.in-project true && \
poetry config installer.max-workers 10

WORKDIR /api

COPY pyproject.toml /api/

# =======================================
# Build image
FROM base AS build

RUN poetry install


# =======================================
# App image
FROM base AS app

COPY --from=build /api/.venv /api/.venv

ENV PATH="/api/.venv/bin:$PATH"
ENV PATH="/api:$PATH"
# ENV PATH="/api/openssa:$PATH"
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH="/"

COPY . /api/

EXPOSE 8080

CMD ["sh", "start.sh"]
86 changes: 86 additions & 0 deletions examples/semiconductor/semiconductor-ui/api/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import os
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from collections import defaultdict
import openai

app = FastAPI()

app.add_middleware(
CORSMiddleware,
allow_origins=[os.environ.get("FRONTEND_URL", "http://localhost:4000")],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

client = openai.OpenAI(api_key=os.environ['OPENAI_API_KEY'])

def call_gpt(prompt):
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are an expert in parsing text into a specific format. Please help me with this task."},
{"role": "user", "content": prompt}
]
)
return response.choices[0].message.content

def parse_recipe_text(text):
parsed_data = {"recipe_1": "", "recipe_2": "", "agent_advice": ""}
lines = text.split("\n")
current_section = None

for line in lines:
if "recipe_1:" in line:
current_section = "recipe_1"
elif "recipe_2:" in line:
current_section = "recipe_2"
elif "agent_advice:" in line:
current_section = "agent_advice"
elif current_section:
parsed_data[current_section] += line + "\n"

parsed_data = {key: value.strip() for key, value in parsed_data.items()}
return parsed_data

def solve_semiconductor_question(question):
solutions = defaultdict(str)

solutions[question] = get_or_create_agent(use_semikong_lm=True).solve(problem=question)

solution = solutions[question]
solution = solution.replace('$', r'\$')

Check notice on line 54 in examples/semiconductor/semiconductor-ui/api/main.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

examples/semiconductor/semiconductor-ui/api/main.py#L54

Trailing whitespace
prompt = f"""{solution} \n\n Please help me parse the above text into this format:\n
recipe_1: Show the recipe 1 here\n
recipe_2: Show the recipe 2 here\n
agent_advice: Show the agent's general considerations here\n
DO NOT forget the key and DO NOT change the key format.
"""
solution = call_gpt(prompt)
parsed_solution = parse_recipe_text(solution)
return parsed_solution

@app.get("/")
async def root():
return {"message": "Hello World"}

@app.get("/data")
async def get_data():
return {"data": "data"}

@app.post("/data")
async def post_data(request: Request):
data = await request.json()
question = data.get('question')
if not question:
return {"error": "No question provided"}, 400

try:
parsed_answer = solve_semiconductor_question(question)
return parsed_answer
except Exception as e:
logger.error(f"Error solving the question: {e}")
return {"error": str(e)}, 500
Fixed Show fixed Hide fixed

17 changes: 17 additions & 0 deletions examples/semiconductor/semiconductor-ui/api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[tool.poetry]
name = "api"
version = "0.1.0"
description = ""
authors = ["Hung Vo <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
uvicorn = "^0.30.5"
fastapi = "^0.112.0"
openai = "^1.40.1"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
1 change: 1 addition & 0 deletions examples/semiconductor/semiconductor-ui/api/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uvicorn main:app --loop "asyncio" --proxy-headers --host 0.0.0.0 --port 8080

Check failure on line 1 in examples/semiconductor/semiconductor-ui/api/start.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

examples/semiconductor/semiconductor-ui/api/start.sh#L1

Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
4 changes: 4 additions & 0 deletions examples/semiconductor/semiconductor-ui/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.step-item::after {
content: '';
border: 1px solid #e0e0e0;
}
31 changes: 31 additions & 0 deletions examples/semiconductor/semiconductor-ui/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "3.9"

services:
apis:
container_name: apis
restart: always
platform: linux/amd64
env_file: .env
build:
context: ./api
dockerfile: ./Dockerfile
command: sh start.sh

ports:
- 9000:8080

ui:
container_name: semiconductor-ui
restart: always
build:
context: ./ui
target: development
dockerfile: ./Dockerfile
environment:
- VITE_API_HOST=http://localhost:9000
volumes:
- ./ui/src:/app/src
- ./ui/public:/app/public
- "./ui/tailwind.config.js:/app/tailwind.config.js"
ports:
- 4000:5173
Loading
Loading